fluent-plugin-reemit 0.3.1 → 0.3.2
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/CHANGELOG.md +6 -0
- data/examples/reemit_filter.conf +23 -0
- data/fluent-plugin-reemit.gemspec +1 -1
- data/lib/fluent/plugin/out_reemit.rb +13 -116
- data/lib/fluent/plugin/out_reemit/v10_event_router.rb +35 -0
- data/lib/fluent/plugin/out_reemit/v12_event_router.rb +73 -0
- data/lib/fluent/plugin/out_reemit/v14_event_router.rb +21 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6de921463dfbc3f21a5b0d55a073d53341bb7b3
|
4
|
+
data.tar.gz: d220a7ff0f0e46050d9fc820ea3694ac67be422d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba582993fad70f50cab375636349284bd4286838bb8206f08126d7f3e29d27ac0aab169c518f23b0bf8113af7cacbc05c22b07645c7b8b73fe2cb9244d3a461
|
7
|
+
data.tar.gz: 185201f75e424cd764a856563741943ddaf399286feae3aa5924b69e07d199d58c612fd4f2d0f5a61a658162af36072f82fd943b89704d19d76b45f3a0d7643f
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
<source>
|
2
|
+
type gc_stat
|
3
|
+
emit_interval 1s
|
4
|
+
tag gc_stat
|
5
|
+
</source>
|
6
|
+
|
7
|
+
<match **>
|
8
|
+
@type copy
|
9
|
+
<store>
|
10
|
+
@type stdout
|
11
|
+
</store>
|
12
|
+
<store>
|
13
|
+
@type reemit
|
14
|
+
</store>
|
15
|
+
</match>
|
16
|
+
|
17
|
+
<filter **>
|
18
|
+
@type stdout
|
19
|
+
</filter>
|
20
|
+
|
21
|
+
<match **>
|
22
|
+
@type stdout
|
23
|
+
</match>
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "fluent-plugin-reemit"
|
6
|
-
gem.version = "0.3.
|
6
|
+
gem.version = "0.3.2"
|
7
7
|
gem.authors = ["Naotoshi Seo"]
|
8
8
|
gem.email = "sonots@gmail.com"
|
9
9
|
gem.homepage = "https://github.com/sonots/fluent-plugin-reemit"
|
@@ -1,10 +1,19 @@
|
|
1
1
|
require 'fluent/version'
|
2
|
-
if Fluent::VERSION > '0.12'
|
3
|
-
require 'fluent/event_router'
|
4
|
-
end
|
5
2
|
|
6
3
|
module Fluent
|
7
4
|
class ReemitOutput < Output
|
5
|
+
major, minor, patch = Fluent::VERSION.split('.').map(&:to_i)
|
6
|
+
if major > 0 || (major == 0 && minor >= 14)
|
7
|
+
require_relative 'out_reemit/v14_event_router'
|
8
|
+
EventRouter = V14EventRouter
|
9
|
+
elsif major == 0 && minor >= 12
|
10
|
+
require_relative 'out_reemit/v12_event_router'
|
11
|
+
EventRouter = V12EventRouter
|
12
|
+
else
|
13
|
+
require_relative 'out_reemit/v10_event_router'
|
14
|
+
EventRouter = V10EventRouter
|
15
|
+
end
|
16
|
+
|
8
17
|
Fluent::Plugin.register_output('reemit', self)
|
9
18
|
|
10
19
|
# To support log_level option implemented by Fluentd v0.10.43
|
@@ -15,14 +24,7 @@ module Fluent
|
|
15
24
|
def configure(conf)
|
16
25
|
super
|
17
26
|
|
18
|
-
|
19
|
-
if major > 0 || (major == 0 && minor >= 14)
|
20
|
-
@router = V14EventRouter.new(self)
|
21
|
-
elsif major == 0 && minor >= 12
|
22
|
-
@router = V12EventRouter.new(self)
|
23
|
-
else
|
24
|
-
@router = V10EventRouter.new(self)
|
25
|
-
end
|
27
|
+
@router = EventRouter.new(self)
|
26
28
|
end
|
27
29
|
|
28
30
|
def start
|
@@ -49,110 +51,5 @@ module Fluent
|
|
49
51
|
false
|
50
52
|
end
|
51
53
|
end
|
52
|
-
|
53
|
-
class V12EventRouter
|
54
|
-
def initialize(reemit)
|
55
|
-
@reemit = reemit
|
56
|
-
@event_router = Engine.root_agent.event_router
|
57
|
-
@chain = @event_router.instance_variable_get(:@chain) # only v0.12
|
58
|
-
@emit_error_handler = @event_router.emit_error_handler
|
59
|
-
@match_rules = @event_router.instance_variable_get(:@match_rules)
|
60
|
-
@default_collector = @event_router.default_collector
|
61
|
-
# @match_cache = @event_router.match_cache
|
62
|
-
@match_cache = EventRouter::MatchCache.new # need to use a different cache
|
63
|
-
end
|
64
|
-
|
65
|
-
# copy from fluentd
|
66
|
-
def emit_stream(tag, es)
|
67
|
-
match(tag).emit(tag, es, @chain)
|
68
|
-
rescue => e
|
69
|
-
@emit_error_handler.handle_emits_error(tag, es, e)
|
70
|
-
end
|
71
|
-
|
72
|
-
# copy from fluentd
|
73
|
-
def match(tag)
|
74
|
-
collector = @match_cache.get(tag) {
|
75
|
-
c = find(tag) || @default_collector
|
76
|
-
}
|
77
|
-
collector
|
78
|
-
end
|
79
|
-
|
80
|
-
def find(tag)
|
81
|
-
# We want to reemit messages to the **next** `<match>`
|
82
|
-
pipeline = nil
|
83
|
-
found_reemit = false
|
84
|
-
@match_rules.each_with_index { |rule, i|
|
85
|
-
# if rule.match?(tag) # this is the original
|
86
|
-
if rule.match?(tag)
|
87
|
-
if found_reemit && !@reemit.included?(rule.collector)
|
88
|
-
if rule.collector.is_a?(Filter)
|
89
|
-
pipeline ||= EventRouter::Pipeline.new
|
90
|
-
pipeline.add_filter(rule.collector)
|
91
|
-
else
|
92
|
-
if pipeline
|
93
|
-
pipeline.set_output(rule.collector)
|
94
|
-
else
|
95
|
-
# Use Output directly when filter is not matched
|
96
|
-
pipeline = rule.collector
|
97
|
-
end
|
98
|
-
return pipeline
|
99
|
-
end
|
100
|
-
elsif !found_reemit && @reemit.included?(rule.collector)
|
101
|
-
found_reemit = true
|
102
|
-
end
|
103
|
-
end
|
104
|
-
}
|
105
|
-
|
106
|
-
if pipeline
|
107
|
-
# filter is matched but no match
|
108
|
-
pipeline.set_output(@default_collector)
|
109
|
-
pipeline
|
110
|
-
else
|
111
|
-
nil
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Almost same as V12EventRouter but it must call #emit_events instead of #emit.
|
117
|
-
class V14EventRouter < V12EventRouter
|
118
|
-
# copy from fluentd
|
119
|
-
def emit_stream(tag, es)
|
120
|
-
match(tag).emit_events(tag, es)
|
121
|
-
rescue => e
|
122
|
-
@emit_error_handler.handle_emits_error(tag, es, e)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class V10EventRouter
|
127
|
-
def initialize(reemit)
|
128
|
-
@reemit = reemit
|
129
|
-
@matches = Engine.matches
|
130
|
-
@match_cache = {}
|
131
|
-
end
|
132
|
-
|
133
|
-
def emit_stream(tag, es)
|
134
|
-
target = @match_cache[tag]
|
135
|
-
unless target
|
136
|
-
target = match(tag) || Fluent::EngineClass::NoMatchMatch.new
|
137
|
-
@match_cache[tag] = target
|
138
|
-
end
|
139
|
-
target.emit(tag, es)
|
140
|
-
end
|
141
|
-
|
142
|
-
def match(tag)
|
143
|
-
# We want to reemit messages to the **next** `<match>`
|
144
|
-
found_reemit = false
|
145
|
-
@matches.find do |m|
|
146
|
-
if m.match(tag)
|
147
|
-
if found_reemit && !@reemit.included?(m.output)
|
148
|
-
true
|
149
|
-
elsif !found_reemit && @reemit.included?(m.output)
|
150
|
-
found_reemit = true
|
151
|
-
false
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
54
|
end
|
158
55
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fluent
|
2
|
+
class ReemitOutput < Output
|
3
|
+
class V10EventRouter
|
4
|
+
def initialize(reemit)
|
5
|
+
@reemit = reemit
|
6
|
+
@matches = Engine.matches
|
7
|
+
@match_cache = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def emit_stream(tag, es)
|
11
|
+
target = @match_cache[tag]
|
12
|
+
unless target
|
13
|
+
target = match(tag) || Fluent::EngineClass::NoMatchMatch.new
|
14
|
+
@match_cache[tag] = target
|
15
|
+
end
|
16
|
+
target.emit(tag, es)
|
17
|
+
end
|
18
|
+
|
19
|
+
def match(tag)
|
20
|
+
# We want to reemit messages to the **next** `<match>`
|
21
|
+
found_reemit = false
|
22
|
+
@matches.find do |m|
|
23
|
+
if m.match(tag)
|
24
|
+
if found_reemit && !@reemit.included?(m.output)
|
25
|
+
true
|
26
|
+
elsif !found_reemit && @reemit.included?(m.output)
|
27
|
+
found_reemit = true
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'fluent/filter'
|
2
|
+
require 'fluent/event_router'
|
3
|
+
|
4
|
+
module Fluent
|
5
|
+
class ReemitOutput < Output
|
6
|
+
class V12EventRouter
|
7
|
+
def filter_class
|
8
|
+
::Fluent::Filter
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(reemit)
|
12
|
+
@reemit = reemit
|
13
|
+
@event_router = Engine.root_agent.event_router
|
14
|
+
@chain = @event_router.instance_variable_get(:@chain) # only v0.12
|
15
|
+
@emit_error_handler = @event_router.emit_error_handler
|
16
|
+
@match_rules = @event_router.instance_variable_get(:@match_rules)
|
17
|
+
@default_collector = @event_router.default_collector
|
18
|
+
# @match_cache = @event_router.match_cache
|
19
|
+
@match_cache = ::Fluent::EventRouter::MatchCache.new # need to use a different cache
|
20
|
+
end
|
21
|
+
|
22
|
+
# copy from fluentd
|
23
|
+
def emit_stream(tag, es)
|
24
|
+
match(tag).emit(tag, es, @chain)
|
25
|
+
rescue => e
|
26
|
+
@emit_error_handler.handle_emits_error(tag, es, e)
|
27
|
+
end
|
28
|
+
|
29
|
+
# copy from fluentd
|
30
|
+
def match(tag)
|
31
|
+
collector = @match_cache.get(tag) {
|
32
|
+
c = find(tag) || @default_collector
|
33
|
+
}
|
34
|
+
collector
|
35
|
+
end
|
36
|
+
|
37
|
+
def find(tag)
|
38
|
+
# We want to reemit messages to the **next** `<match>`
|
39
|
+
pipeline = nil
|
40
|
+
found_reemit = false
|
41
|
+
@match_rules.each_with_index { |rule, i|
|
42
|
+
# if rule.match?(tag) # this is the original
|
43
|
+
if rule.match?(tag)
|
44
|
+
if found_reemit && !@reemit.included?(rule.collector)
|
45
|
+
if rule.collector.is_a?(filter_class)
|
46
|
+
pipeline ||= ::Fluent::EventRouter::Pipeline.new
|
47
|
+
pipeline.add_filter(rule.collector)
|
48
|
+
else
|
49
|
+
if pipeline
|
50
|
+
pipeline.set_output(rule.collector)
|
51
|
+
else
|
52
|
+
# Use Output directly when filter is not matched
|
53
|
+
pipeline = rule.collector
|
54
|
+
end
|
55
|
+
return pipeline
|
56
|
+
end
|
57
|
+
elsif !found_reemit && @reemit.included?(rule.collector)
|
58
|
+
found_reemit = true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
}
|
62
|
+
|
63
|
+
if pipeline
|
64
|
+
# filter is matched but no match
|
65
|
+
pipeline.set_output(@default_collector)
|
66
|
+
pipeline
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'v12_event_router'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class ReemitOutput < Output
|
5
|
+
# Almost same as V12EventRouter but
|
6
|
+
# (1) it must call #emit_events instead of #emit
|
7
|
+
# (2) Filter class is Fluent::Plugin::Filter instead of Fluent::Filter
|
8
|
+
class V14EventRouter < V12EventRouter
|
9
|
+
def filter_class
|
10
|
+
::Fluent::Plugin::Filter
|
11
|
+
end
|
12
|
+
|
13
|
+
# copy from fluentd
|
14
|
+
def emit_stream(tag, es)
|
15
|
+
match(tag).emit_events(tag, es)
|
16
|
+
rescue => e
|
17
|
+
@emit_error_handler.handle_emits_error(tag, es, e)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-reemit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
@@ -112,8 +112,12 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- examples/multiple_reemit.conf
|
114
114
|
- examples/reemit.conf
|
115
|
+
- examples/reemit_filter.conf
|
115
116
|
- fluent-plugin-reemit.gemspec
|
116
117
|
- lib/fluent/plugin/out_reemit.rb
|
118
|
+
- lib/fluent/plugin/out_reemit/v10_event_router.rb
|
119
|
+
- lib/fluent/plugin/out_reemit/v12_event_router.rb
|
120
|
+
- lib/fluent/plugin/out_reemit/v14_event_router.rb
|
117
121
|
- spec/out_reemit_spec.rb
|
118
122
|
- spec/spec_helper.rb
|
119
123
|
homepage: https://github.com/sonots/fluent-plugin-reemit
|
@@ -136,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
140
|
version: '0'
|
137
141
|
requirements: []
|
138
142
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.5.1
|
140
144
|
signing_key:
|
141
145
|
specification_version: 4
|
142
146
|
summary: Fluentd plugin to re-emit messages avoiding infinity match loop
|