fluent-plugin-json_serializer 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
11
+ td-agent
12
+ Dockerfile
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-json-serializer.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # Fluent::Plugin::Json::Serializer
2
+
3
+ ## 概要
4
+
5
+ * TD-agent v0.12以降で動作する、filterプラグインです
6
+ * fluentdに来たrecordを、1つのキーに収納します
7
+
8
+ ## plugin詳細
9
+
10
+ ```
11
+ {
12
+ "action":"login",
13
+ "user":2
14
+ }
15
+ ```
16
+
17
+ こういった形のtd-agentデータを
18
+
19
+ ```
20
+ {
21
+ "message" : {
22
+ "action":"login",
23
+ "user":2
24
+ }
25
+ }
26
+ ```
27
+ こういう形に変換します。(field_nameに「message」を指定したとき)
28
+
29
+
30
+ ## Installation
31
+ td-agent 0.12.0 以上
32
+
33
+ ```
34
+ $ cd /usr/local/src
35
+ $ git clone ssh://git@stash.gu3.jp:7999/error-handling/fluent-plugin-json-serializer.git
36
+ $ cd ./fluent-plugin-json-serializer
37
+ $ /usr/lib64/fluent/ruby/bin/rake build
38
+ $ /opt/td-agent/embedded/bin/fluent-gem install pkg/fluent-plugin-json-serializer
39
+ ```
40
+
41
+
42
+ ## Usage
43
+
44
+ ```
45
+ <filter **>
46
+ type serializer
47
+ field_name message
48
+ </filter>
49
+
50
+ <match **>
51
+ type stdout
52
+ </match>
53
+ ```
54
+
55
+ ## ToDo
56
+
57
+ * READMEを充実
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-json-serializer/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fluent/plugin/json/serializer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-json_serializer"
7
+ spec.version = "0.0.4"
8
+ spec.authors = ["Zaki_XL"]
9
+ spec.email = ["heavenzdrive@gmail.com"]
10
+
11
+ if spec.respond_to?(:metadata)
12
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
13
+ end
14
+
15
+ spec.summary = %q{fluent plugin for Json serialize}
16
+ spec.description = %q{fluent plugin for Json serialize}
17
+ spec.homepage = "http://need4answer.blogspot.jp/"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.8"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+
28
+ spec.add_dependency "fluentd", ">= 0.12.00"
29
+ spec.add_dependency "oj", "~> 2.11"
30
+
31
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'oj'
3
+
4
+ module Fluent
5
+ class Fluent::JsonSerializerFilter < Fluent::Filter
6
+ Fluent::Plugin.register_filter('serializer', self)
7
+
8
+ # config ------------------------------
9
+ config_param :field_name, :string, :default => "message"
10
+
11
+ # log Level ---------------------------
12
+ unless method_defined?(:log)
13
+ define_method("log") { $log }
14
+ end
15
+
16
+ # Load config -------------------------
17
+ def configure(conf)
18
+ super
19
+ end
20
+
21
+ # Start -------------------------------
22
+ def start
23
+ super
24
+ end
25
+
26
+ # Shutdown ---------------------------
27
+ def shutdown
28
+ super
29
+ end
30
+
31
+ # main --------------------------------
32
+
33
+ # Edit Data
34
+ def filter(tag, time, record)
35
+ new_record = Hash.new()
36
+ new_record[@field_name] = convert_to_json(record)
37
+
38
+ # return
39
+ new_record
40
+ end
41
+
42
+ # private -----------------------------
43
+ private
44
+
45
+ # Convert record to json
46
+ def convert_to_json(record)
47
+ Oj.dump(record, :mode => :compat)
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,25 @@
1
+ #==========================================
2
+ # Port待ち受け
3
+ #==========================================
4
+ <source>
5
+ type forward
6
+ port 24224
7
+ </source>
8
+
9
+ <source>
10
+ type http
11
+ port 8888
12
+ bind 0.0.0.0
13
+ body_size_limit 32m
14
+ keepalive_timeout 10s
15
+ </source>
16
+
17
+ <filter *>
18
+ type serializer
19
+ tag ${tag}
20
+ field_name message
21
+ </filter>
22
+
23
+ <match *>
24
+ type stdout
25
+ </match>
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-json_serializer
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 4
9
+ version: 0.0.4
10
+ platform: ruby
11
+ authors:
12
+ - Zaki_XL
13
+ autorequire:
14
+ bindir: exe
15
+ cert_chain: []
16
+
17
+ date: 2015-04-09 00:00:00 +09:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bundler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 8
30
+ version: "1.8"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 10
42
+ - 0
43
+ version: "10.0"
44
+ type: :development
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: fluentd
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ - 12
56
+ - 0
57
+ version: 0.12.00
58
+ type: :runtime
59
+ version_requirements: *id003
60
+ - !ruby/object:Gem::Dependency
61
+ name: oj
62
+ prerelease: false
63
+ requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 2
69
+ - 11
70
+ version: "2.11"
71
+ type: :runtime
72
+ version_requirements: *id004
73
+ description: fluent plugin for Json serialize
74
+ email:
75
+ - heavenzdrive@gmail.com
76
+ executables: []
77
+
78
+ extensions: []
79
+
80
+ extra_rdoc_files: []
81
+
82
+ files:
83
+ - .gitignore
84
+ - Gemfile
85
+ - LICENSE.txt
86
+ - README.md
87
+ - Rakefile
88
+ - bin/console
89
+ - bin/setup
90
+ - fluent-plugin-json_serializer.gemspec
91
+ - lib/fluent/plugin/filter_serializer.rb
92
+ - td-agent.conf
93
+ has_rdoc: true
94
+ homepage: http://need4answer.blogspot.jp/
95
+ licenses:
96
+ - MIT
97
+ post_install_message:
98
+ rdoc_options: []
99
+
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirements: []
117
+
118
+ rubyforge_project:
119
+ rubygems_version: 1.3.6
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: fluent plugin for Json serialize
123
+ test_files: []
124
+