fluent-plugin-config-expander 0.2.1 → 1.0.0
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 +2 -2
- data/README.md +4 -3
- data/fluent-plugin-config-expander.gemspec +2 -2
- data/lib/fluent/plugin/expander.rb +2 -2
- data/lib/fluent/plugin/filter_config_expander.rb +50 -0
- data/lib/fluent/plugin/in_config_expander.rb +20 -22
- data/lib/fluent/plugin/out_config_expander.rb +22 -30
- data/test/helper.rb +6 -1
- data/test/plugin/test_in_config_expander.rb +16 -16
- data/test/plugin/test_out_config_expander.rb +35 -32
- data/test/plugins.rb +23 -23
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f027aae70a497c28fe302e764006f38d4a63b9c9
|
4
|
+
data.tar.gz: a921f29a8cf2689cd975d69bbb728112dac7b97b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84b3bd584a5378fbaa9a48e2364d6a1b280d93ad248c68c127fd4b9151781526d5a2bfebd8121e87333d0cc80a1e32fbaf09c74f9e213d81b722beaa631b0174
|
7
|
+
data.tar.gz: 7d5adde5590ab2c3b18c6221390cb281585d29434daf8b06ca899151f0825268700d8df4e6b58a96ef09bd5ab1f65a8dc4f0dfc1f259e3661921ed9f2dc9d821
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,15 +4,15 @@ This is a plugin for [Fluentd](http://fluentd.org).
|
|
4
4
|
|
5
5
|
## ConfigExpanderInput, ConfigExpanderOutput
|
6
6
|
|
7
|
-
ConfigExpanderInput and ConfigExpanderOutput plugins provide simple configuration template to write items repeatedly.
|
8
|
-
In <config> section, you can write actual configuration for actual input/output plugin, with special directives for loop controls.
|
7
|
+
ConfigExpanderInput, ConfigExpanderFilter and ConfigExpanderOutput plugins provide simple configuration template to write items repeatedly.
|
8
|
+
In <config> section, you can write actual configuration for actual input/filter/output plugin, with special directives for loop controls.
|
9
9
|
|
10
10
|
And also supports built-in placeholders below:
|
11
11
|
* hostname (ex: \_\_HOSTNAME\_\_, \_\_hostname\_\_, ${hostname}, ${HOSTNAME})
|
12
12
|
|
13
13
|
## Configuration
|
14
14
|
|
15
|
-
For
|
15
|
+
For all of input, filter and output (for <source>, <filter> and <match>), you can use 'config_expander' and its 'for' directive like below:
|
16
16
|
|
17
17
|
<match example.**>
|
18
18
|
@type config_expander
|
@@ -87,6 +87,7 @@ Set hostname into tag in 'tail' input plugin:
|
|
87
87
|
@type config_expander
|
88
88
|
<config>
|
89
89
|
@type tail
|
90
|
+
@label @access_events
|
90
91
|
format /..../
|
91
92
|
path /var/log/access.log
|
92
93
|
tag access.log.${hostname}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-config-expander"
|
5
|
-
gem.version = "0.
|
5
|
+
gem.version = "1.0.0"
|
6
6
|
gem.authors = ["TAGOMORI Satoshi"]
|
7
7
|
gem.email = ["tagomoris@gmail.com"]
|
8
8
|
gem.description = %q{This plugin provides directives for loop extraction}
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
|
18
|
-
gem.add_runtime_dependency "fluentd", "
|
18
|
+
gem.add_runtime_dependency "fluentd", ">= 0.14.0"
|
19
19
|
gem.add_development_dependency "rake"
|
20
20
|
gem.add_development_dependency "test-unit", "~> 3.1"
|
21
21
|
end
|
@@ -2,13 +2,13 @@ require 'fluent/config'
|
|
2
2
|
|
3
3
|
module Fluent::Config::Expander
|
4
4
|
def self.replace(str, mapping)
|
5
|
-
mapping.reduce(str){|r,
|
5
|
+
mapping.reduce(str){|r, pair| r.gsub(pair[0], pair[1])}
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.expand(element, mapping)
|
9
9
|
name = replace(element.name, mapping)
|
10
10
|
arg = replace(element.arg, mapping)
|
11
|
-
attrs = element.reduce({}){|r,
|
11
|
+
attrs = element.reduce({}){|r, pair| r[replace(pair[0], mapping)] = replace(pair[1], mapping); r}
|
12
12
|
elements = []
|
13
13
|
element.elements.each do |e|
|
14
14
|
if e.name == 'for'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'fluent/plugin/filter'
|
2
|
+
|
3
|
+
require_relative 'expander'
|
4
|
+
require 'forwardable'
|
5
|
+
require 'socket'
|
6
|
+
|
7
|
+
class Fluent::Plugin::ConfigExpanderFilter < Fluent::Plugin::Filter
|
8
|
+
Fluent::Plugin.register_input('config_expander', self)
|
9
|
+
|
10
|
+
config_param :hostname, :string, default: Socket.gethostname
|
11
|
+
config_section :config, multi: false, required: true, param_name: :config_config do
|
12
|
+
# to raise configuration error for missing section
|
13
|
+
end
|
14
|
+
|
15
|
+
def mark_used(conf)
|
16
|
+
conf.keys.each {|key| conf[key] } # to suppress unread configuration warning
|
17
|
+
conf.elements.each{|e| mark_used(e)}
|
18
|
+
end
|
19
|
+
|
20
|
+
def builtin_mapping
|
21
|
+
{'__hostname__' => @hostname, '__HOSTNAME__' => @hostname, '${hostname}' => @hostname, '${HOSTNAME}' => @hostname}
|
22
|
+
end
|
23
|
+
|
24
|
+
def expand_config(conf)
|
25
|
+
ex = Fluent::Config::Expander.expand(conf, builtin_mapping())
|
26
|
+
ex.name = 'filter' # name/arg will be ignored by Plugin#configure, but anyway
|
27
|
+
ex.arg = conf.arg
|
28
|
+
ex
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure(conf)
|
32
|
+
super
|
33
|
+
|
34
|
+
ex = expand_config(@config_config.corresponding_config_element)
|
35
|
+
type = ex['@type']
|
36
|
+
@plugin = Fluent::Plugin.new_input(type)
|
37
|
+
@plugin.context_router = self.event_emitter_router(conf['@label'])
|
38
|
+
@plugin.configure(ex)
|
39
|
+
mark_used(@config_config.corresponding_config_element)
|
40
|
+
|
41
|
+
self.extend SingleForwardable
|
42
|
+
override_methods = self.methods + @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods
|
43
|
+
override_methods.uniq!
|
44
|
+
def_delegators(:@plugin, *override_methods)
|
45
|
+
end
|
46
|
+
|
47
|
+
def method_missing(name, *args, &block)
|
48
|
+
@plugin.__send__(name, *args, &block)
|
49
|
+
end
|
50
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
|
+
require 'fluent/plugin/input'
|
2
|
+
|
1
3
|
require_relative 'expander'
|
4
|
+
require 'forwardable'
|
5
|
+
require 'socket'
|
2
6
|
|
3
|
-
class Fluent::ConfigExpanderInput < Fluent::Input
|
7
|
+
class Fluent::Plugin::ConfigExpanderInput < Fluent::Plugin::Input
|
4
8
|
Fluent::Plugin.register_input('config_expander', self)
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
config_param :hostname, :string, default: Socket.gethostname
|
11
|
+
config_section :config, multi: false, required: true, param_name: :config_config do
|
12
|
+
# to raise configuration error for missing section
|
9
13
|
end
|
10
14
|
|
11
|
-
config_param :hostname, :string, :default => `hostname`.chomp
|
12
|
-
attr_accessor :plugin
|
13
|
-
|
14
15
|
def mark_used(conf)
|
15
16
|
conf.keys.each {|key| conf[key] } # to suppress unread configuration warning
|
16
17
|
conf.elements.each{|e| mark_used(e)}
|
@@ -22,31 +23,28 @@ class Fluent::ConfigExpanderInput < Fluent::Input
|
|
22
23
|
|
23
24
|
def expand_config(conf)
|
24
25
|
ex = Fluent::Config::Expander.expand(conf, builtin_mapping())
|
25
|
-
ex.name = ''
|
26
|
+
ex.name = 'source' # name/arg will be ignored by Plugin#configure, but anyway
|
26
27
|
ex.arg = ''
|
27
28
|
ex
|
28
29
|
end
|
29
30
|
|
30
31
|
def configure(conf)
|
31
32
|
super
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
raise Fluent::ConfigError, "config_expander needs just one <config> ... </config> section"
|
36
|
-
end
|
37
|
-
ex = expand_config(configs.first)
|
38
|
-
type = ex['@type'] || ex['type']
|
33
|
+
|
34
|
+
ex = expand_config(@config_config.corresponding_config_element)
|
35
|
+
type = ex['@type']
|
39
36
|
@plugin = Fluent::Plugin.new_input(type)
|
37
|
+
@plugin.context_router = self.event_emitter_router(conf['@label'])
|
40
38
|
@plugin.configure(ex)
|
39
|
+
mark_used(@config_config.corresponding_config_element)
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@plugin.start
|
41
|
+
self.extend SingleForwardable
|
42
|
+
override_methods = self.methods + @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods
|
43
|
+
override_methods.uniq!
|
44
|
+
def_delegators(:@plugin, *override_methods)
|
47
45
|
end
|
48
46
|
|
49
|
-
def
|
50
|
-
@plugin.
|
47
|
+
def method_missing(name, *args, &block)
|
48
|
+
@plugin.__send__(name, *args, &block)
|
51
49
|
end
|
52
50
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
require 'fluent/plugin/bare_output'
|
2
|
+
|
1
3
|
require_relative 'expander'
|
4
|
+
require 'forwardable'
|
5
|
+
require 'socket'
|
2
6
|
|
3
|
-
class Fluent::ConfigExpanderOutput < Fluent::
|
7
|
+
class Fluent::Plugin::ConfigExpanderOutput < Fluent::Plugin::BareOutput
|
4
8
|
Fluent::Plugin.register_output('config_expander', self)
|
5
9
|
|
6
|
-
|
7
|
-
unless method_defined?(:log)
|
8
|
-
define_method("log") { $log }
|
9
|
-
end
|
10
|
+
helpers :event_emitter
|
10
11
|
|
11
|
-
config_param :hostname, :string, :
|
12
|
-
|
12
|
+
config_param :hostname, :string, default: Socket.gethostname
|
13
|
+
config_section :config, multi: false, required: true, param_name: :config_config do
|
14
|
+
# to raise configuration error for missing section
|
15
|
+
end
|
13
16
|
|
14
17
|
def mark_used(conf)
|
15
18
|
conf.keys.each {|key| conf[key] } # to suppress unread configuration warning
|
@@ -22,39 +25,28 @@ class Fluent::ConfigExpanderOutput < Fluent::MultiOutput
|
|
22
25
|
|
23
26
|
def expand_config(conf)
|
24
27
|
ex = Fluent::Config::Expander.expand(conf, builtin_mapping())
|
25
|
-
ex.name = ''
|
26
|
-
ex.arg =
|
28
|
+
ex.name = 'match' # name/arg will be ignored by Plugin#configure, but anyway
|
29
|
+
ex.arg = conf.arg
|
27
30
|
ex
|
28
31
|
end
|
29
32
|
|
30
|
-
attr_reader :outputs
|
31
|
-
|
32
33
|
def configure(conf)
|
33
34
|
super
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
raise Fluent::ConfigError, "config_expander needs just one <config> ... </config> section"
|
38
|
-
end
|
39
|
-
ex = expand_config(configs.first)
|
40
|
-
type = ex['@type'] || ex['type']
|
36
|
+
ex = expand_config(@config_config.corresponding_config_element)
|
37
|
+
type = ex['@type']
|
41
38
|
@plugin = Fluent::Plugin.new_output(type)
|
39
|
+
@plugin.context_router = self.event_emitter_router(conf['@label'])
|
42
40
|
@plugin.configure(ex)
|
41
|
+
mark_used(@config_config.corresponding_config_element)
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
def start
|
50
|
-
@plugin.start
|
51
|
-
end
|
52
|
-
|
53
|
-
def shutdown
|
54
|
-
@plugin.shutdown
|
43
|
+
self.extend SingleForwardable
|
44
|
+
override_methods = self.methods + @plugin.methods - SingleForwardable.instance_methods - Object.instance_methods
|
45
|
+
override_methods.uniq!
|
46
|
+
def_delegators(:@plugin, *override_methods)
|
55
47
|
end
|
56
48
|
|
57
|
-
def
|
58
|
-
@plugin.
|
49
|
+
def method_missing(name, *args, &block)
|
50
|
+
@plugin.__send__(name, *args, &block)
|
59
51
|
end
|
60
52
|
end
|
data/test/helper.rb
CHANGED
@@ -12,7 +12,6 @@ require 'test/unit'
|
|
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
|
-
require 'fluent/input'
|
16
15
|
unless ENV.has_key?('VERBOSE')
|
17
16
|
nulllogger = Object.new
|
18
17
|
nulllogger.instance_eval {|obj|
|
@@ -23,7 +22,13 @@ unless ENV.has_key?('VERBOSE')
|
|
23
22
|
$log = nulllogger
|
24
23
|
end
|
25
24
|
|
25
|
+
require 'fluent/test/driver/input'
|
26
|
+
require 'fluent/test/driver/filter'
|
27
|
+
require 'fluent/test/driver/base_owner' # for output (BareOutput)
|
28
|
+
require 'fluent/test/driver/event_feeder'
|
29
|
+
|
26
30
|
require 'fluent/plugin/in_config_expander'
|
31
|
+
require 'fluent/plugin/filter_config_expander'
|
27
32
|
require 'fluent/plugin/out_config_expander'
|
28
33
|
|
29
34
|
class Test::Unit::TestCase
|
@@ -20,24 +20,24 @@ type config_expander
|
|
20
20
|
]
|
21
21
|
|
22
22
|
def create_driver(conf=CONFIG)
|
23
|
-
Fluent::Test::
|
23
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::ConfigExpanderInput).configure(conf)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_configure
|
27
27
|
d = create_driver
|
28
|
-
assert_equal 'foobar', d.instance.
|
29
|
-
assert_equal 3, d.instance.
|
30
|
-
assert_equal ['1','2','3'], d.instance.
|
28
|
+
assert_equal 'foobar', d.instance.tag
|
29
|
+
assert_equal 3, d.instance.nodes.size
|
30
|
+
assert_equal ['1','2','3'], d.instance.nodes.map{|n| n.attr1 }.sort
|
31
31
|
|
32
|
-
assert_equal false, d.instance.
|
33
|
-
assert_equal false, d.instance.
|
32
|
+
assert_equal false, d.instance.started
|
33
|
+
assert_equal false, d.instance.stopped
|
34
34
|
|
35
35
|
d.instance.start()
|
36
|
-
assert_equal true, d.instance.
|
37
|
-
assert_equal false, d.instance.
|
38
|
-
|
36
|
+
assert_equal true, d.instance.started
|
37
|
+
assert_equal false, d.instance.stopped
|
38
|
+
|
39
39
|
d.instance.shutdown()
|
40
|
-
assert_equal true, d.instance.
|
40
|
+
assert_equal true, d.instance.stopped
|
41
41
|
end
|
42
42
|
|
43
43
|
CONFIG2 = %[
|
@@ -52,14 +52,14 @@ hostname testing.node.local
|
|
52
52
|
attr3 __hostname__
|
53
53
|
attr4 __HOSTNAME__
|
54
54
|
</node>
|
55
|
+
</config>
|
55
56
|
]
|
56
57
|
def test_configure_hostname
|
57
58
|
d = create_driver CONFIG2
|
58
|
-
assert_equal 1, d.instance.
|
59
|
-
assert_equal 'testing.node.local', d.instance.
|
60
|
-
assert_equal 'testing.node.local', d.instance.
|
61
|
-
assert_equal 'testing.node.local', d.instance.
|
62
|
-
assert_equal 'testing.node.local', d.instance.
|
59
|
+
assert_equal 1, d.instance.nodes.size
|
60
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr1
|
61
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr2
|
62
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr3
|
63
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr4
|
63
64
|
end
|
64
|
-
|
65
65
|
end
|
@@ -18,25 +18,28 @@ type config_expander
|
|
18
18
|
</for>
|
19
19
|
</config>
|
20
20
|
]
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
def create_driver(conf=CONFIG)
|
23
|
+
d = Fluent::Test::Driver::BaseOwner.new(Fluent::Plugin::ConfigExpanderOutput)
|
24
|
+
d.extend Fluent::Test::Driver::EventFeeder
|
25
|
+
d.configure(conf)
|
23
26
|
end
|
24
27
|
|
25
28
|
def test_configure
|
26
29
|
d = create_driver
|
27
|
-
assert_equal 'foobar', d.instance.
|
28
|
-
assert_equal 3, d.instance.
|
29
|
-
assert_equal ['1','2','3'], d.instance.
|
30
|
+
assert_equal 'foobar', d.instance.tag
|
31
|
+
assert_equal 3, d.instance.nodes.size
|
32
|
+
assert_equal ['1','2','3'], d.instance.nodes.map{|n| n.attr1 }.sort
|
30
33
|
|
31
|
-
assert_equal false, d.instance.
|
32
|
-
assert_equal false, d.instance.
|
34
|
+
assert_equal false, d.instance.started
|
35
|
+
assert_equal false, d.instance.stopped
|
33
36
|
|
34
37
|
d.instance.start()
|
35
|
-
assert_equal true, d.instance.
|
36
|
-
assert_equal false, d.instance.
|
37
|
-
|
38
|
+
assert_equal true, d.instance.started
|
39
|
+
assert_equal false, d.instance.stopped
|
40
|
+
|
38
41
|
d.instance.shutdown()
|
39
|
-
assert_equal true, d.instance.
|
42
|
+
assert_equal true, d.instance.stopped
|
40
43
|
end
|
41
44
|
|
42
45
|
CONFIG2 = %[
|
@@ -51,38 +54,38 @@ hostname testing.node.local
|
|
51
54
|
attr3 __hostname__
|
52
55
|
attr4 __HOSTNAME__
|
53
56
|
</node>
|
57
|
+
</config>
|
54
58
|
]
|
55
59
|
def test_configure_hostname
|
56
60
|
d = create_driver CONFIG2
|
57
|
-
assert_equal 1, d.instance.
|
58
|
-
assert_equal 'testing.node.local', d.instance.
|
59
|
-
assert_equal 'testing.node.local', d.instance.
|
60
|
-
assert_equal 'testing.node.local', d.instance.
|
61
|
-
assert_equal 'testing.node.local', d.instance.
|
61
|
+
assert_equal 1, d.instance.nodes.size
|
62
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr1
|
63
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr2
|
64
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr3
|
65
|
+
assert_equal 'testing.node.local', d.instance.nodes.first.attr4
|
62
66
|
end
|
63
67
|
|
64
68
|
def test_emit
|
65
69
|
d = create_driver
|
66
|
-
d.run do
|
67
|
-
d.
|
68
|
-
d.
|
69
|
-
d.
|
70
|
+
d.run(default_tag: 'test.default', expect_records: 3) do
|
71
|
+
d.feed({'field' => 'value1'})
|
72
|
+
d.feed({'field' => 'value2'})
|
73
|
+
d.feed({'field' => 'value3'})
|
70
74
|
end
|
71
75
|
|
72
|
-
|
73
|
-
assert_equal 3,
|
76
|
+
events = d.events
|
77
|
+
assert_equal 3, events.size
|
74
78
|
|
75
|
-
assert_equal 'foobar',
|
76
|
-
assert_equal 'value1',
|
77
|
-
assert_equal 'expander',
|
79
|
+
assert_equal 'foobar', events[0][0]
|
80
|
+
assert_equal 'value1', events[0][2]['field']
|
81
|
+
assert_equal 'expander', events[0][2]['over']
|
78
82
|
|
79
|
-
assert_equal 'foobar',
|
80
|
-
assert_equal 'value2',
|
81
|
-
assert_equal 'expander',
|
83
|
+
assert_equal 'foobar', events[1][0]
|
84
|
+
assert_equal 'value2', events[1][2]['field']
|
85
|
+
assert_equal 'expander', events[1][2]['over']
|
82
86
|
|
83
|
-
assert_equal 'foobar',
|
84
|
-
assert_equal 'value3',
|
85
|
-
assert_equal 'expander',
|
87
|
+
assert_equal 'foobar', events[2][0]
|
88
|
+
assert_equal 'value3', events[2][2]['field']
|
89
|
+
assert_equal 'expander', events[2][2]['over']
|
86
90
|
end
|
87
|
-
|
88
91
|
end
|
data/test/plugins.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/input'
|
2
|
+
|
3
|
+
class Fluent::Plugin::ConfigExpanderTestInput < Fluent::Plugin::Input
|
2
4
|
Fluent::Plugin.register_input('config_expander_test', self)
|
3
5
|
|
4
6
|
config_param :tag, :string
|
5
|
-
|
7
|
+
config_section :node, param_name: :nodes, multi: true do
|
8
|
+
config_param :attr1, :string, default: nil
|
9
|
+
config_param :attr2, :string, default: nil
|
10
|
+
config_param :attr3, :string, default: nil
|
11
|
+
config_param :attr4, :string, default: nil
|
12
|
+
end
|
6
13
|
attr_accessor :started, :stopped
|
7
14
|
|
8
15
|
def configure(conf)
|
9
16
|
super
|
10
|
-
@nodes = []
|
11
|
-
conf.elements.each do |e|
|
12
|
-
next if e.name != 'node'
|
13
|
-
@nodes << {}.merge(e)
|
14
|
-
end
|
15
17
|
@started = @stopped = false
|
16
18
|
end
|
17
19
|
def start
|
@@ -19,25 +21,29 @@ class Fluent::ConfigExpanderTestInput < Fluent::Input
|
|
19
21
|
@started = true
|
20
22
|
end
|
21
23
|
def shutdown
|
22
|
-
super
|
23
24
|
@stopped = true
|
25
|
+
super
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
|
29
|
+
require 'fluent/plugin/output'
|
30
|
+
|
31
|
+
class Fluent::Plugin::ConfigExpanderTestOutput < Fluent::Plugin::Output
|
28
32
|
Fluent::Plugin.register_output('config_expander_test', self)
|
29
33
|
|
34
|
+
helpers :event_emitter
|
35
|
+
|
30
36
|
config_param :tag, :string
|
31
|
-
|
37
|
+
config_section :node, param_name: :nodes, multi: true do
|
38
|
+
config_param :attr1, :string, default: nil
|
39
|
+
config_param :attr2, :string, default: nil
|
40
|
+
config_param :attr3, :string, default: nil
|
41
|
+
config_param :attr4, :string, default: nil
|
42
|
+
end
|
32
43
|
attr_accessor :started, :stopped
|
33
44
|
|
34
45
|
def configure(conf)
|
35
46
|
super
|
36
|
-
@nodes = []
|
37
|
-
conf.elements.each do |e|
|
38
|
-
next if e.name != 'node'
|
39
|
-
@nodes << {}.merge(e)
|
40
|
-
end
|
41
47
|
@started = @stopped = false
|
42
48
|
end
|
43
49
|
def start
|
@@ -45,19 +51,13 @@ class Fluent::ConfigExpanderTestOutput < Fluent::Output
|
|
45
51
|
@started = true
|
46
52
|
end
|
47
53
|
def shutdown
|
48
|
-
super
|
49
54
|
@stopped = true
|
55
|
+
super
|
50
56
|
end
|
51
57
|
|
52
|
-
|
53
|
-
unless method_defined?(:router)
|
54
|
-
define_method("router") { Fluent::Engine }
|
55
|
-
end
|
56
|
-
|
57
|
-
def emit(tag, es, chain)
|
58
|
+
def process(tag, es)
|
58
59
|
es.each do |time, record|
|
59
60
|
router.emit(@tag, time, record.merge({'over' => 'expander'}))
|
60
61
|
end
|
61
|
-
chain.next
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-config-expander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.14.0
|
20
20
|
type: :runtime
|
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: 0.14.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- fluent-plugin-config-expander.gemspec
|
69
69
|
- lib/fluent/plugin/expander.rb
|
70
|
+
- lib/fluent/plugin/filter_config_expander.rb
|
70
71
|
- lib/fluent/plugin/in_config_expander.rb
|
71
72
|
- lib/fluent/plugin/out_config_expander.rb
|
72
73
|
- test/helper.rb
|