fluent-plugin-add 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/LICENSE.txt +22 -1
- data/README.md +19 -2
- data/Rakefile +1 -1
- data/fluent-plugin-add.gemspec +3 -1
- data/lib/fluent/plugin/filter_add.rb +28 -0
- data/lib/fluent/plugin/out_add.rb +6 -5
- data/test/helper.rb +2 -1
- data/test/plugin/test_filter_add.rb +36 -0
- data/test/plugin/test_out_add.rb +24 -9
- metadata +42 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf64a5f84f157f3c6a8df0255db7bcb35c6a0c3
|
4
|
+
data.tar.gz: 57146af805319e37dbbe649cca5d3eecb6eb064c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cdf4a85caea8d2102544180de4a55a137227a8c351f16181fa99765d1d759e2a84f8b0bdb4fed1d3373870f2c472b5cef457a521af0d41bb73a4e4b8abd67cd
|
7
|
+
data.tar.gz: 2b0956a4286ae55b22f7e9e712c949b191e40f73d84d5ec599596574eb7bfb52e6224073e3cd7f9abb09e56ba190f271c22c5424e83d4d8a94d0781a46868d2a
|
data/.travis.yml
ADDED
data/LICENSE.txt
CHANGED
@@ -1 +1,22 @@
|
|
1
|
-
Copyright (c) 2013 yu-yamada
|
1
|
+
Copyright (c) 2013 yu-yamada
|
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.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# fluent-plugin-add
|
2
|
-
|
1
|
+
# fluent-plugin-add, a plugin for [Fluentd](http://fluentd.org)
|
2
|
+
[](https://travis-ci.org/yu-yamada/fluent-plugin-add)
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
|
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
## Configration
|
10
10
|
|
11
|
+
### AddOutput
|
12
|
+
|
11
13
|
<match test.**>
|
12
14
|
type add
|
13
15
|
add_tag_prefix debug
|
@@ -23,6 +25,21 @@
|
|
23
25
|
### then output bocomes as belows
|
24
26
|
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge"}
|
25
27
|
|
28
|
+
### AddFilter
|
29
|
+
|
30
|
+
<filter test.**>
|
31
|
+
type add
|
32
|
+
<pair>
|
33
|
+
hoge moge
|
34
|
+
hogehoge mogemoge
|
35
|
+
</pair>
|
36
|
+
</filter>
|
37
|
+
|
38
|
+
|
39
|
+
### Assuming following inputs are coming:
|
40
|
+
test.aa: {"json":"dayo"}
|
41
|
+
### then output bocomes as belows
|
42
|
+
debug.test.aa: {"json":"dayo", "hoge":"moge","hogehoge":"mogemoge"}
|
26
43
|
|
27
44
|
## Contributing
|
28
45
|
|
data/Rakefile
CHANGED
data/fluent-plugin-add.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "fluent-plugin-add"
|
8
|
-
spec.version = "0.0.
|
8
|
+
spec.version = "0.0.4"
|
9
9
|
spec.authors = ["yu yamada"]
|
10
10
|
spec.email = ["yu.yamada07@gmail.com"]
|
11
11
|
spec.description = %q{Output filter plugin to add messages}
|
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "test-unit", "~> 3.1.0"
|
24
|
+
spec.add_runtime_dependency "fluentd"
|
23
25
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Fluent::AddFilter < Fluent::Filter
|
2
|
+
Fluent::Plugin.register_filter('add', self)
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def configure(conf)
|
9
|
+
super
|
10
|
+
|
11
|
+
@add_hash = Hash.new
|
12
|
+
|
13
|
+
conf.elements.select {|element|
|
14
|
+
element.name == 'pair'
|
15
|
+
}.each do |pair|
|
16
|
+
pair.each do | k,v|
|
17
|
+
@add_hash[k] = v
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter(tag, time, record)
|
23
|
+
@add_hash.each do |k,v|
|
24
|
+
record[k] = v
|
25
|
+
end
|
26
|
+
record
|
27
|
+
end
|
28
|
+
end if defined?(Fluent::Filter)
|
@@ -1,7 +1,11 @@
|
|
1
|
-
require 'pp'
|
2
1
|
class Fluent::AddOutput < Fluent::Output
|
3
2
|
Fluent::Plugin.register_output('add', self)
|
4
3
|
|
4
|
+
# Define `router` method of v0.12 to support v0.10.57 or earlier
|
5
|
+
unless method_defined?(:router)
|
6
|
+
define_method("router") { Fluent::Engine }
|
7
|
+
end
|
8
|
+
|
5
9
|
config_param :add_tag_prefix, :string, :default => 'greped'
|
6
10
|
|
7
11
|
def initialize
|
@@ -11,8 +15,6 @@ class Fluent::AddOutput < Fluent::Output
|
|
11
15
|
def configure(conf)
|
12
16
|
super
|
13
17
|
|
14
|
-
# @key = @key.to_s
|
15
|
-
# @value = @value.to_s
|
16
18
|
@tag_prefix = "#{@add_tag_prefix}."
|
17
19
|
@add_hash = Hash.new
|
18
20
|
|
@@ -35,11 +37,10 @@ class Fluent::AddOutput < Fluent::Output
|
|
35
37
|
emit_tag = @tag_proc.call(tag)
|
36
38
|
|
37
39
|
es.each do |time,record|
|
38
|
-
# record[@key] = @value
|
39
40
|
@add_hash.each do |k,v|
|
40
41
|
record[k] = v
|
41
42
|
end
|
42
|
-
|
43
|
+
router.emit(emit_tag, time, record)
|
43
44
|
end
|
44
45
|
|
45
46
|
chain.next
|
data/test/helper.rb
CHANGED
@@ -11,7 +11,7 @@ require 'test/unit'
|
|
11
11
|
|
12
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
-
|
14
|
+
require 'fluent/test'
|
15
15
|
unless ENV.has_key?('VERBOSE')
|
16
16
|
nulllogger = Object.new
|
17
17
|
nulllogger.instance_eval {|obj|
|
@@ -23,6 +23,7 @@ unless ENV.has_key?('VERBOSE')
|
|
23
23
|
end
|
24
24
|
|
25
25
|
require 'fluent/plugin/out_add'
|
26
|
+
require 'fluent/plugin/filter_add'
|
26
27
|
|
27
28
|
class Test::Unit::TestCase
|
28
29
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AddFilterTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
omit("Use Fluentd v0.12 or later.") unless defined?(Fluent::Filter)
|
6
|
+
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
CONFIG = %[
|
11
|
+
<pair>
|
12
|
+
hoge moge
|
13
|
+
hogehoge mogemoge
|
14
|
+
</pair>
|
15
|
+
]
|
16
|
+
|
17
|
+
def create_driver(conf = CONFIG, tag='test')
|
18
|
+
Fluent::Test::FilterTestDriver.new(Fluent::AddFilter, tag).configure(conf)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_configure
|
22
|
+
d = create_driver
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_format
|
26
|
+
d = create_driver
|
27
|
+
|
28
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
29
|
+
d.run do
|
30
|
+
d.filter("a" => 1)
|
31
|
+
end
|
32
|
+
mapped = {'hoge' => 'moge', 'hogehoge' => 'mogemoge'}
|
33
|
+
expect = {"a" => 1}.merge(mapped)
|
34
|
+
assert_equal expect, d.filtered_as_array[0][2]
|
35
|
+
end
|
36
|
+
end
|
data/test/plugin/test_out_add.rb
CHANGED
@@ -6,19 +6,34 @@ class AddOutputTest < Test::Unit::TestCase
|
|
6
6
|
end
|
7
7
|
|
8
8
|
CONFIG = %[
|
9
|
+
add_tag_prefix pre_hoge
|
10
|
+
<pair>
|
11
|
+
hoge moge
|
12
|
+
hogehoge mogemoge
|
13
|
+
</pair>
|
9
14
|
]
|
10
|
-
|
11
|
-
# path #{TMP_DIR}/out_file_test
|
12
|
-
# compress gz
|
13
|
-
# utc
|
14
|
-
# ]
|
15
|
-
|
15
|
+
|
16
16
|
def create_driver(conf = CONFIG, tag='test')
|
17
|
-
Fluent::Test::
|
17
|
+
Fluent::Test::OutputTestDriver.new(Fluent::AddOutput, tag).configure(conf)
|
18
18
|
end
|
19
19
|
|
20
|
-
def test_configure
|
20
|
+
def test_configure
|
21
|
+
d = create_driver
|
22
|
+
assert_equal 'pre_hoge', d.instance.config["add_tag_prefix"]
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
def test_format
|
26
|
+
d = create_driver
|
27
|
+
|
28
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
29
|
+
d.run do
|
30
|
+
d.emit("a" => 1)
|
31
|
+
end
|
32
|
+
mapped = {'hoge' => 'moge', 'hogehoge' => 'mogemoge'}
|
33
|
+
assert_equal [
|
34
|
+
{"a" => 1}.merge(mapped),
|
35
|
+
], d.records
|
24
36
|
|
37
|
+
d.run
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-add
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yu yamada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluentd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
description: Output filter plugin to add messages
|
@@ -45,14 +73,17 @@ executables: []
|
|
45
73
|
extensions: []
|
46
74
|
extra_rdoc_files: []
|
47
75
|
files:
|
48
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
49
78
|
- Gemfile
|
50
79
|
- LICENSE.txt
|
51
80
|
- README.md
|
52
81
|
- Rakefile
|
53
82
|
- fluent-plugin-add.gemspec
|
83
|
+
- lib/fluent/plugin/filter_add.rb
|
54
84
|
- lib/fluent/plugin/out_add.rb
|
55
85
|
- test/helper.rb
|
86
|
+
- test/plugin/test_filter_add.rb
|
56
87
|
- test/plugin/test_out_add.rb
|
57
88
|
homepage: https://github.com/yu-yamada/fluent-plugin-add
|
58
89
|
licenses:
|
@@ -64,20 +95,21 @@ require_paths:
|
|
64
95
|
- lib
|
65
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
97
|
requirements:
|
67
|
-
- -
|
98
|
+
- - ">="
|
68
99
|
- !ruby/object:Gem::Version
|
69
100
|
version: '0'
|
70
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
102
|
requirements:
|
72
|
-
- -
|
103
|
+
- - ">="
|
73
104
|
- !ruby/object:Gem::Version
|
74
105
|
version: '0'
|
75
106
|
requirements: []
|
76
107
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.2.2
|
78
109
|
signing_key:
|
79
110
|
specification_version: 4
|
80
111
|
summary: Output filter plugin to add messages
|
81
112
|
test_files:
|
82
113
|
- test/helper.rb
|
114
|
+
- test/plugin/test_filter_add.rb
|
83
115
|
- test/plugin/test_out_add.rb
|