fluent-plugin-replace 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d96e67513cea7cd337a16e6a9c998956556a02e
4
+ data.tar.gz: 6c2580ba3c57c523d5520d45d8b29a13f5ccebba
5
+ SHA512:
6
+ metadata.gz: dd707c5f0b142f1b0915c1a26971e26c1a07632ab020a2992dff77b1b2d2437c8761d860b77d4473fe3b0255e087bc28f02eda771a51c2eded592c426d1a3f8a
7
+ data.tar.gz: 272b88ae7cbb295751318eec080f33478fc83e352695e84cc035aac8c2a093b433474f53c3d4a812df3bc0d96dc14b91364e49f8a958a2c2a07a62144fe780dc
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-replace.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 kaihar4
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Fluent::Plugin::Replace
2
+
3
+ Fluentd plugin to replace the string with specified YAML.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ $ gem install fluent-plugin-replace
9
+ ```
10
+
11
+ ### Example
12
+
13
+ ```
14
+ <match test>
15
+ type replace
16
+ rules_yaml $HOME/fluent/test_rules.yml
17
+ tag replaced.test
18
+ </match>
19
+
20
+ <match replaced.test>
21
+ type stdout
22
+ </match>
23
+ ```
24
+
25
+ ```
26
+ # test_rules.yml
27
+
28
+ ip:
29
+ - 127.0.0.1: 'localhost'
30
+ ```
31
+
32
+ ```
33
+ $ echo '{"ip":"127.0.0.1","host":"foobar.com"}' | fluent-cat test
34
+ {"ip":"localhost","host":"foobar.com"}
35
+ ```
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH << File.expand_path('../lib', __FILE__)
2
+ require 'fluent/plugin/replace/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'fluent-plugin-replace'
6
+ spec.version = Fluent::Plugin::Replace::VERSION
7
+ spec.authors = ['kaihar4']
8
+ spec.email = ['kaihar4@gmail.com']
9
+ spec.summary = 'Fluentd plugin to replace the string with specified YAML'
10
+ spec.description = spec.summary
11
+ spec.homepage = 'https://github.com/kaihar4/fluent-plugin-replace'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_development_dependency 'bundler'
20
+ spec.add_development_dependency 'rake'
21
+ spec.add_development_dependency 'pry'
22
+ spec.add_development_dependency 'awesome_print'
23
+ end
@@ -0,0 +1,34 @@
1
+ require 'yaml'
2
+
3
+ class Fluent::ReplaceOutput < Fluent::Output
4
+ Fluent::Plugin.register_output('replace', self)
5
+
6
+ config_param :rules_yaml, :string
7
+ config_param :tag, :string, default: nil
8
+
9
+ def configure(conf)
10
+ super
11
+
12
+ @rules = YAML.load_file(@rules_yaml) rescue nil
13
+ raise Fluent::ConfigError, "#{@rules_yaml} is not found" unless @rules
14
+ end
15
+
16
+ def emit(tag, es, chain)
17
+ tag = @tag if @tag
18
+
19
+ es.each do |time, record|
20
+ begin
21
+ @rules.each do |key, array|
22
+ array.each do |rule|
23
+ record[key] = rule[record[key]] if rule.keys.include?(record[key])
24
+ end
25
+ end
26
+ rescue
27
+ raise Fluent::ConfigError, 'Invalid YAML format'
28
+ end
29
+ Fluent::Engine.emit(tag, time, record)
30
+ end
31
+
32
+ chain.next
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Fluent
2
+ module Plugin
3
+ module Replace
4
+ VERSION = '0.0.1'
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-replace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kaihar4
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Fluentd plugin to replace the string with specified YAML
70
+ email:
71
+ - kaihar4@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - fluent-plugin-replace.gemspec
82
+ - lib/fluent/plugin/out_replace.rb
83
+ - lib/fluent/plugin/replace/version.rb
84
+ homepage: https://github.com/kaihar4/fluent-plugin-replace
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Fluentd plugin to replace the string with specified YAML
108
+ test_files: []