fluent-plugin-filter 0.0.5 → 0.1.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 -0
- data/fluent-plugin-filter.gemspec +2 -2
- data/lib/fluent/plugin/filter_filter.rb +4 -3
- data/lib/fluent/plugin/filter_util.rb +1 -1
- data/lib/fluent/plugin/out_filter.rb +9 -5
- data/test/plugin/test_filter_filter.rb +11 -10
- data/test/plugin/test_out_filter.rb +47 -46
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677804cde241741f2449565acd4400e4020b5078
|
4
|
+
data.tar.gz: 4fba58dbc973ae62fa23e5894d0f324ff6dfc0a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1acce40701456fe992258b189574214f74afdb3b7403a84cbc9760c6e83358ee8ff36ca43ff34eb826ac3bbd890f6c1f5c02f801b3cbf7b3e3ad5ec6176cc73
|
7
|
+
data.tar.gz: 60ccbab7eb21d8ba9181b5aa13446508785642d4ead72711938aa2b755f7e663f8498b49a37f3fbdecd8209db6cfdb6cd4f37ca2095c69e7cc9ba236d1569012
|
data/.travis.yml
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "fluent-plugin-filter"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "0.0
|
15
|
+
gem.version = "0.1.0"
|
16
16
|
|
17
17
|
gem.extra_rdoc_files = [
|
18
18
|
"ChangeLog",
|
@@ -20,5 +20,5 @@ Gem::Specification.new do |gem|
|
|
20
20
|
]
|
21
21
|
gem.add_development_dependency "rake"
|
22
22
|
gem.add_development_dependency "test-unit", "~> 3.1.0"
|
23
|
-
gem.add_runtime_dependency "fluentd"
|
23
|
+
gem.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
|
24
24
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/filter_util'
|
2
|
+
require 'fluent/plugin/filter'
|
3
|
+
module Fluent::Plugin
|
2
4
|
class FilterFilter < Filter
|
3
|
-
require 'fluent/plugin/filter_util'
|
4
5
|
include FilterUtil
|
5
6
|
|
6
|
-
Plugin.register_filter('filter', self)
|
7
|
+
Fluent::Plugin.register_filter('filter', self)
|
7
8
|
|
8
9
|
config_param :all, :string, :default => 'allow'
|
9
10
|
config_param :allow, :string, :default => ''
|
@@ -1,9 +1,14 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/filter_util'
|
2
|
+
require 'fluent/plugin/output'
|
3
|
+
|
4
|
+
module Fluent::Plugin
|
2
5
|
class FilterOutput < Output
|
3
|
-
|
6
|
+
|
7
|
+
helpers :event_emitter
|
8
|
+
|
4
9
|
include FilterUtil
|
5
10
|
|
6
|
-
Plugin.register_output('filter', self)
|
11
|
+
Fluent::Plugin.register_output('filter', self)
|
7
12
|
|
8
13
|
config_param :all, :string, :default => 'allow'
|
9
14
|
config_param :allow, :string, :default => ''
|
@@ -25,7 +30,7 @@ class FilterOutput < Output
|
|
25
30
|
define_method("router") { Fluent::Engine }
|
26
31
|
end
|
27
32
|
|
28
|
-
def
|
33
|
+
def process(tag, es)
|
29
34
|
if @add_prefix
|
30
35
|
tag = @add_prefix + '.' + tag
|
31
36
|
end
|
@@ -33,7 +38,6 @@ class FilterOutput < Output
|
|
33
38
|
next unless passRules(record)
|
34
39
|
router.emit(tag, time, record)
|
35
40
|
end
|
36
|
-
chain.next
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'helper'
|
3
|
+
require 'fluent/test/driver/filter'
|
3
4
|
|
4
5
|
class TestFilterFilter < Test::Unit::TestCase
|
5
6
|
def setup
|
@@ -11,8 +12,8 @@ class TestFilterFilter < Test::Unit::TestCase
|
|
11
12
|
deny status: 404
|
12
13
|
]
|
13
14
|
|
14
|
-
def create_driver(conf = CONFIG
|
15
|
-
Fluent::Test::
|
15
|
+
def create_driver(conf = CONFIG)
|
16
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::FilterFilter).configure(conf)
|
16
17
|
end
|
17
18
|
|
18
19
|
data("int value" => [{"allows" => [['status', 200]], "denies" => []},
|
@@ -104,13 +105,13 @@ class TestFilterFilter < Test::Unit::TestCase
|
|
104
105
|
{'status' => 200, 'agent' => 'Gecka', 'path' => '/users/3'},
|
105
106
|
{'status' => 404, 'agent' => 'Gecko', 'path' => '/wrong'},
|
106
107
|
]
|
107
|
-
d = create_driver(target
|
108
|
-
d.run do
|
108
|
+
d = create_driver(target)
|
109
|
+
d.run(default_tag: 'test') do
|
109
110
|
inputs.each do |dat|
|
110
|
-
d.
|
111
|
+
d.feed dat
|
111
112
|
end
|
112
113
|
end
|
113
|
-
assert_equal expected, d.
|
114
|
+
assert_equal expected, d.filtered.map{|e| e.last}.length
|
114
115
|
end
|
115
116
|
|
116
117
|
data("allow message2" => [1,
|
@@ -129,12 +130,12 @@ class TestFilterFilter < Test::Unit::TestCase
|
|
129
130
|
{'message' => 'hoge', 'message2' => 'hoge2'},
|
130
131
|
{'message' => 'hoge3'},
|
131
132
|
]
|
132
|
-
d = create_driver(target
|
133
|
-
d.run do
|
133
|
+
d = create_driver(target)
|
134
|
+
d.run(default_tag: 'test.input') do
|
134
135
|
inputs.each do |dat|
|
135
|
-
d.
|
136
|
+
d.feed dat
|
136
137
|
end
|
137
138
|
end
|
138
|
-
assert_equal expected, d.
|
139
|
+
assert_equal expected, d.filtered.map{|e| e.last}.length
|
139
140
|
end
|
140
141
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'helper'
|
3
|
+
require 'fluent/test/driver/output'
|
3
4
|
|
4
5
|
class Filter < Test::Unit::TestCase
|
5
6
|
def setup
|
@@ -11,8 +12,8 @@ class Filter < Test::Unit::TestCase
|
|
11
12
|
deny status: 404
|
12
13
|
]
|
13
14
|
|
14
|
-
def create_driver(conf = CONFIG
|
15
|
-
Fluent::Test::
|
15
|
+
def create_driver(conf = CONFIG)
|
16
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::FilterOutput).configure(conf)
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_configure
|
@@ -102,104 +103,104 @@ class Filter < Test::Unit::TestCase
|
|
102
103
|
{'status' => 404, 'agent' => 'Gecko', 'path' => '/wrong'},
|
103
104
|
]
|
104
105
|
|
105
|
-
d = create_driver(CONFIG
|
106
|
-
d.run do
|
106
|
+
d = create_driver(CONFIG)
|
107
|
+
d.run(default_tag: 'test.input') do
|
107
108
|
data.each do |dat|
|
108
|
-
d.
|
109
|
+
d.feed dat
|
109
110
|
end
|
110
111
|
end
|
111
|
-
assert_equal 5, d.
|
112
|
+
assert_equal 5, d.events.length
|
112
113
|
|
113
114
|
d = create_driver(%[
|
114
115
|
all deny
|
115
116
|
allow status: 200
|
116
|
-
]
|
117
|
-
d.run do
|
117
|
+
])
|
118
|
+
d.run(default_tag: 'test.input') do
|
118
119
|
data.each do |dat|
|
119
|
-
d.
|
120
|
+
d.feed dat
|
120
121
|
end
|
121
122
|
end
|
122
|
-
assert_equal 3, d.
|
123
|
+
assert_equal 3, d.events.length
|
123
124
|
|
124
125
|
d = create_driver(%[
|
125
126
|
all deny
|
126
127
|
allow status: 200, status: 303
|
127
|
-
]
|
128
|
-
d.run do
|
128
|
+
])
|
129
|
+
d.run(default_tag: 'test.input') do
|
129
130
|
data.each do |dat|
|
130
|
-
d.
|
131
|
+
d.feed dat
|
131
132
|
end
|
132
133
|
end
|
133
|
-
assert_equal 4, d.
|
134
|
+
assert_equal 4, d.events.length
|
134
135
|
|
135
136
|
d = create_driver(%[
|
136
137
|
all deny
|
137
138
|
allow agent: Gecko
|
138
|
-
]
|
139
|
-
d.run do
|
139
|
+
])
|
140
|
+
d.run(default_tag: 'test.input') do
|
140
141
|
data.each do |dat|
|
141
|
-
d.
|
142
|
+
d.feed dat
|
142
143
|
end
|
143
144
|
end
|
144
|
-
assert_equal 3, d.
|
145
|
+
assert_equal 3, d.events.length
|
145
146
|
|
146
147
|
d = create_driver(%[
|
147
148
|
all deny
|
148
149
|
allow agent: "Gecko"
|
149
|
-
]
|
150
|
-
d.run do
|
150
|
+
])
|
151
|
+
d.run(default_tag: 'test') do
|
151
152
|
data.each do |dat|
|
152
|
-
d.
|
153
|
+
d.feed dat
|
153
154
|
end
|
154
155
|
end
|
155
|
-
assert_equal 3, d.
|
156
|
+
assert_equal 3, d.events.length
|
156
157
|
|
157
158
|
d = create_driver(%[
|
158
159
|
all deny
|
159
160
|
allow agent: "Gecko"
|
160
161
|
deny status: 200
|
161
|
-
]
|
162
|
-
d.run do
|
162
|
+
])
|
163
|
+
d.run(default_tag: 'test.input') do
|
163
164
|
data.each do |dat|
|
164
|
-
d.
|
165
|
+
d.feed dat
|
165
166
|
end
|
166
167
|
end
|
167
|
-
assert_equal 3, d.
|
168
|
+
assert_equal 3, d.events.length
|
168
169
|
|
169
170
|
d = create_driver(%[
|
170
171
|
all deny
|
171
172
|
allow agent: /Geck/
|
172
|
-
]
|
173
|
-
d.run do
|
173
|
+
])
|
174
|
+
d.run(default_tag: 'test') do
|
174
175
|
data.each do |dat|
|
175
|
-
d.
|
176
|
+
d.feed dat
|
176
177
|
end
|
177
178
|
end
|
178
|
-
assert_equal 4, d.
|
179
|
+
assert_equal 4, d.events.length
|
179
180
|
|
180
181
|
d = create_driver(%[
|
181
182
|
all deny
|
182
183
|
allow agent: /Geck/
|
183
184
|
add_prefix hoge
|
184
|
-
]
|
185
|
-
d.run do
|
185
|
+
])
|
186
|
+
d.run(default_tag: 'test.input') do
|
186
187
|
data.each do |dat|
|
187
|
-
d.
|
188
|
+
d.feed dat
|
188
189
|
end
|
189
190
|
end
|
190
|
-
assert_equal "hoge.test.input", d.
|
191
|
+
assert_equal "hoge.test.input", d.events[0][0]
|
191
192
|
|
192
193
|
d = create_driver(%[
|
193
194
|
all deny
|
194
195
|
allow path: /\\/users\\/\\d+/
|
195
|
-
]
|
196
|
+
])
|
196
197
|
|
197
|
-
d.run do
|
198
|
+
d.run(default_tag: 'test.input') do
|
198
199
|
data.each do |dat|
|
199
|
-
d.
|
200
|
+
d.feed dat
|
200
201
|
end
|
201
202
|
end
|
202
|
-
assert_equal 3, d.
|
203
|
+
assert_equal 3, d.events.length
|
203
204
|
|
204
205
|
data = [
|
205
206
|
{'message' => 'hoge', 'message2' => 'hoge2'},
|
@@ -209,26 +210,26 @@ class Filter < Test::Unit::TestCase
|
|
209
210
|
d = create_driver(%[
|
210
211
|
all deny
|
211
212
|
allow message2: /hoge2/
|
212
|
-
]
|
213
|
+
])
|
213
214
|
|
214
|
-
d.run do
|
215
|
+
d.run(default_tag: 'test.input') do
|
215
216
|
data.each do |dat|
|
216
|
-
d.
|
217
|
+
d.feed dat
|
217
218
|
end
|
218
219
|
end
|
219
|
-
assert_equal 1, d.
|
220
|
+
assert_equal 1, d.events.length
|
220
221
|
|
221
222
|
d = create_driver(%[
|
222
223
|
all allow
|
223
224
|
deny message2: /hoge2/
|
224
|
-
]
|
225
|
+
])
|
225
226
|
|
226
|
-
d.run do
|
227
|
+
d.run(default_tag: 'test.input') do
|
227
228
|
data.each do |dat|
|
228
|
-
d.
|
229
|
+
d.feed dat
|
229
230
|
end
|
230
231
|
end
|
231
|
-
assert_equal 1, d.
|
232
|
+
assert_equal 1, d.events.length
|
232
233
|
|
233
234
|
end
|
234
235
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muddy Dixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,14 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.14.15
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
57
|
+
version: 0.14.15
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
55
61
|
description: Simple output filter
|
56
62
|
email:
|
57
63
|
- muddydixon@gmail.com
|
@@ -95,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
101
|
version: '0'
|
96
102
|
requirements: []
|
97
103
|
rubyforge_project: fluent-plugin-filter
|
98
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.6.13
|
99
105
|
signing_key:
|
100
106
|
specification_version: 4
|
101
107
|
summary: Simple output filter
|