fluent-plugin-conditional_filter 0.0.2 → 0.0.3
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 +4 -5
- data/README.md +22 -1
- data/fluent-plugin-conditional_filter.gemspec +2 -2
- data/lib/fluent/plugin/out_conditional_filter.rb +7 -1
- data/spec/lib/out_conditional_filter_spec.rb +112 -0
- data/spec/spec_helper.rb +3 -0
- metadata +29 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc5c490e9566041f5cd52dcdbccaa2e37db1477
|
4
|
+
data.tar.gz: bd5605aeb0b2ed35045020e9b1a45ab0e9206146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cda736e9cdbddc4e0d4cdec38f9c5e913bec91817c3d4085209d07d0be6164abb11615679e29bdd4b2e326b965ea5ad5bc30ce01c9aba078dde35db84926dca
|
7
|
+
data.tar.gz: d5d9fef02572bc606b5877382b045f1ede9975682a425d314b2d91423da8ab767308512c03b019eda1aac89e7afe677e31ea244ea6e913f63244f8b486df9694
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Fluent::Plugin::ConditionalFilter [](http://travis-ci.org/kentaro/fluent-plugin-conditional_filter)
|
1
|
+
# Fluent::Plugin::ConditionalFilter, a plugin for [Fluentd](http://fluentd.org) [](http://travis-ci.org/kentaro/fluent-plugin-conditional_filter)
|
2
2
|
|
3
3
|
## Component
|
4
4
|
|
@@ -10,8 +10,11 @@ fluent-plugin-conditional_filter provides a simple filter that filters out key/v
|
|
10
10
|
|
11
11
|
### Synopsis
|
12
12
|
|
13
|
+
If there's such a configuration as below:
|
14
|
+
|
13
15
|
```
|
14
16
|
<match test.**>
|
17
|
+
type conditional_filter
|
15
18
|
add_tag_prefix filtered.
|
16
19
|
key_pattern @example\.com$
|
17
20
|
condition 10
|
@@ -19,6 +22,24 @@ fluent-plugin-conditional_filter provides a simple filter that filters out key/v
|
|
19
22
|
</match>
|
20
23
|
```
|
21
24
|
|
25
|
+
When the log below reaches:
|
26
|
+
|
27
|
+
```
|
28
|
+
'test' => {
|
29
|
+
'foo@example.com' => 5,
|
30
|
+
'bar@example.com' => 15,
|
31
|
+
'baz@baz.com' => 12,
|
32
|
+
}
|
33
|
+
```
|
34
|
+
|
35
|
+
key/value pairs that don't match either `key_pattern` or the condition designated by `condition` and `filter` are filtered out.
|
36
|
+
|
37
|
+
```
|
38
|
+
'filtered.test' => {
|
39
|
+
'bar@example.com' => 15,
|
40
|
+
}
|
41
|
+
```
|
42
|
+
|
22
43
|
### Params
|
23
44
|
|
24
45
|
#### `key_pattern` (required)
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'fluent-plugin-conditional_filter'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.3'
|
8
8
|
spec.authors = ['Kentaro Kuribayashi']
|
9
9
|
spec.email = ['kentarok@gmail.com']
|
10
10
|
spec.description = %q{A fluent plugin that provides conditional filters}
|
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'bundler'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'test-unit'
|
25
26
|
end
|
26
|
-
|
@@ -1,6 +1,11 @@
|
|
1
1
|
class Fluent::ConditionalFilterOutput < Fluent::Output
|
2
2
|
Fluent::Plugin.register_output('conditional_filter', self)
|
3
3
|
|
4
|
+
# Define `router` method of v0.12 to support v0.10 or earlier
|
5
|
+
unless method_defined?(:router)
|
6
|
+
define_method("router") { Fluent::Engine }
|
7
|
+
end
|
8
|
+
|
4
9
|
include Fluent::HandleTagNameMixin
|
5
10
|
|
6
11
|
config_param :key_pattern, :string
|
@@ -26,7 +31,7 @@ class Fluent::ConditionalFilterOutput < Fluent::Output
|
|
26
31
|
record = filter_record(t, time, record)
|
27
32
|
|
28
33
|
if record.any?
|
29
|
-
|
34
|
+
router.emit(t, time, record)
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
@@ -36,6 +41,7 @@ class Fluent::ConditionalFilterOutput < Fluent::Output
|
|
36
41
|
private
|
37
42
|
|
38
43
|
def filter_record(tag, time, record)
|
44
|
+
super
|
39
45
|
case filter
|
40
46
|
when 'numeric_upward'
|
41
47
|
filter_record = record.select do |key, value|
|
@@ -225,6 +225,118 @@ describe Fluent::ConditionalFilterOutput do
|
|
225
225
|
}
|
226
226
|
end
|
227
227
|
end
|
228
|
+
|
229
|
+
context('add_tag_prefix') do
|
230
|
+
let(:conf) {
|
231
|
+
%[
|
232
|
+
add_tag_prefix filtered.
|
233
|
+
key_pattern @example.com$
|
234
|
+
condition 10
|
235
|
+
filter numeric_upward
|
236
|
+
]
|
237
|
+
}
|
238
|
+
|
239
|
+
let(:driver) { Fluent::Test::OutputTestDriver.new(described_class, 'test').configure(conf) }
|
240
|
+
subject {
|
241
|
+
driver.instance
|
242
|
+
}
|
243
|
+
|
244
|
+
context('add tag prefix') do
|
245
|
+
before {
|
246
|
+
driver.run {
|
247
|
+
driver.emit('foo@example.com' => 12, 'bar@example.com' => 6, 'baz@baz.com' => 15)
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
it {
|
252
|
+
expect(driver.emits[0][0]).to be == 'filtered.test'
|
253
|
+
}
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context('remove_tag_prefix') do
|
258
|
+
let(:conf) {
|
259
|
+
%[
|
260
|
+
remove_tag_prefix filtered.
|
261
|
+
key_pattern @example.com$
|
262
|
+
condition 10
|
263
|
+
filter numeric_upward
|
264
|
+
]
|
265
|
+
}
|
266
|
+
|
267
|
+
let(:driver) { Fluent::Test::OutputTestDriver.new(described_class, 'filtered.filtered.test').configure(conf) }
|
268
|
+
subject {
|
269
|
+
driver.instance
|
270
|
+
}
|
271
|
+
|
272
|
+
context('remove tag prefix') do
|
273
|
+
before {
|
274
|
+
driver.run {
|
275
|
+
driver.emit('foo@example.com' => 12, 'bar@example.com' => 6, 'baz@baz.com' => 15)
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
it {
|
280
|
+
expect(driver.emits[0][0]).to be == 'filtered.test'
|
281
|
+
}
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context('add_tag_suffix') do
|
286
|
+
let(:conf) {
|
287
|
+
%[
|
288
|
+
add_tag_suffix .test
|
289
|
+
key_pattern @example.com$
|
290
|
+
condition 10
|
291
|
+
filter numeric_upward
|
292
|
+
]
|
293
|
+
}
|
294
|
+
|
295
|
+
let(:driver) { Fluent::Test::OutputTestDriver.new(described_class, 'filtered').configure(conf) }
|
296
|
+
subject {
|
297
|
+
driver.instance
|
298
|
+
}
|
299
|
+
|
300
|
+
context('add tag suffix') do
|
301
|
+
before {
|
302
|
+
driver.run {
|
303
|
+
driver.emit('foo@example.com' => 12, 'bar@example.com' => 6, 'baz@baz.com' => 15)
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
it {
|
308
|
+
expect(driver.emits[0][0]).to be == 'filtered.test'
|
309
|
+
}
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
context('remove_tag_suffix') do
|
314
|
+
let(:conf) {
|
315
|
+
%[
|
316
|
+
remove_tag_suffix .filtered
|
317
|
+
key_pattern @example.com$
|
318
|
+
condition 10
|
319
|
+
filter numeric_upward
|
320
|
+
]
|
321
|
+
}
|
322
|
+
|
323
|
+
let(:driver) { Fluent::Test::OutputTestDriver.new(described_class, 'filtered.test.filtered').configure(conf) }
|
324
|
+
subject {
|
325
|
+
driver.instance
|
326
|
+
}
|
327
|
+
|
328
|
+
context('remove tag prefix') do
|
329
|
+
before {
|
330
|
+
driver.run {
|
331
|
+
driver.emit('foo@example.com' => 12, 'bar@example.com' => 6, 'baz@baz.com' => 15)
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
it {
|
336
|
+
expect(driver.emits[0][0]).to be == 'filtered.test'
|
337
|
+
}
|
338
|
+
end
|
339
|
+
end
|
228
340
|
end
|
229
341
|
end
|
230
342
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-conditional_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Kuribayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
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'
|
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'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
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
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: A fluent plugin that provides conditional filters
|
@@ -73,8 +87,8 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
78
92
|
- Gemfile
|
79
93
|
- LICENSE.txt
|
80
94
|
- README.md
|
@@ -93,17 +107,17 @@ require_paths:
|
|
93
107
|
- lib
|
94
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
109
|
requirements:
|
96
|
-
- -
|
110
|
+
- - ">="
|
97
111
|
- !ruby/object:Gem::Version
|
98
112
|
version: '0'
|
99
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
requirements: []
|
105
119
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.6.11
|
107
121
|
signing_key:
|
108
122
|
specification_version: 4
|
109
123
|
summary: A fluent plugin that provides conditional filters
|