fluent-plugin-filter 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.rdoc +12 -0
- data/fluent-plugin-filter.gemspec +1 -1
- data/lib/fluent/plugin/filter_filter.rb +3 -2
- data/lib/fluent/plugin/filter_util.rb +2 -2
- data/lib/fluent/plugin/out_filter.rb +9 -3
- data/test/plugin/test_filter_filter.rb +15 -1
- data/test/plugin/test_out_filter.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be8cf5ff3ab2e36b58ddea36e60630cb2e4a337d
|
4
|
+
data.tar.gz: 3ac6af56a55b316e3e889763e962a2df39517cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d5e44650f926f86e45445dc3a9eddc6d5f758f3089ef2e09e1907bb7acf6fe1efe33b5a43f829269cc124d296092dbff87c5536507d46d1b3b9a89537f1013
|
7
|
+
data.tar.gz: 7a5b25fee4361ffdd08958d8ac1b20abec0d00e5c97873332c7e6ed10d96e59f9ee25400938ffd7262feb0f8b6a89a4fd440c553953248594952a3fdec4d0968
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -42,6 +42,18 @@ So you catch "filtered" tag and do next process.
|
|
42
42
|
|
43
43
|
You can use int, float, string, regexp in value.
|
44
44
|
|
45
|
+
=== FilterFilter
|
46
|
+
|
47
|
+
In fluentd >= 0.12, we can use `filter` declarative. So release Filter filter:
|
48
|
+
|
49
|
+
<filter accesslog.**>
|
50
|
+
type filter
|
51
|
+
all allow
|
52
|
+
deny status: 404
|
53
|
+
</filter>
|
54
|
+
|
55
|
+
Thanks to @cosmo0920
|
56
|
+
|
45
57
|
=== Parameters
|
46
58
|
|
47
59
|
==== all <allow|deny>
|
@@ -8,14 +8,15 @@ class FilterFilter < Filter
|
|
8
8
|
config_param :all, :string, :default => 'allow'
|
9
9
|
config_param :allow, :string, :default => ''
|
10
10
|
config_param :deny, :string, :default => ''
|
11
|
+
config_param :delim, :string, :default => ','
|
11
12
|
|
12
13
|
attr_accessor :allows
|
13
14
|
attr_accessor :denies
|
14
15
|
|
15
16
|
def configure(conf)
|
16
17
|
super
|
17
|
-
@allows = toMap(@allow)
|
18
|
-
@denies = toMap(@deny)
|
18
|
+
@allows = toMap(@allow, @delim)
|
19
|
+
@denies = toMap(@deny, @delim)
|
19
20
|
end
|
20
21
|
|
21
22
|
def filter(tag, time, record)
|
@@ -9,14 +9,20 @@ class FilterOutput < Output
|
|
9
9
|
config_param :allow, :string, :default => ''
|
10
10
|
config_param :deny, :string, :default => ''
|
11
11
|
config_param :add_prefix, :string, :default => 'filtered'
|
12
|
+
config_param :delim, :string, :default => ','
|
12
13
|
|
13
14
|
attr_accessor :allows
|
14
15
|
attr_accessor :denies
|
15
16
|
|
16
17
|
def configure(conf)
|
17
18
|
super
|
18
|
-
@allows = toMap(@allow)
|
19
|
-
@denies = toMap(@deny)
|
19
|
+
@allows = toMap(@allow, @delim)
|
20
|
+
@denies = toMap(@deny, @delim)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Define `router` method of v0.12 to support v0.10 or earlier
|
24
|
+
unless method_defined?(:router)
|
25
|
+
define_method("router") { Fluent::Engine }
|
20
26
|
end
|
21
27
|
|
22
28
|
def emit(tag, es, chain)
|
@@ -25,7 +31,7 @@ class FilterOutput < Output
|
|
25
31
|
end
|
26
32
|
es.each do |time, record|
|
27
33
|
next unless passRules(record)
|
28
|
-
|
34
|
+
router.emit(tag, time, record)
|
29
35
|
end
|
30
36
|
chain.next
|
31
37
|
end
|
@@ -41,7 +41,21 @@ class TestFilterFilter < Test::Unit::TestCase
|
|
41
41
|
%[
|
42
42
|
all deny
|
43
43
|
allow url: /\\/users\\/\\d+/
|
44
|
-
]]
|
44
|
+
]],
|
45
|
+
"test values" =>
|
46
|
+
[{"allows" => [['message', 'CRIT'], ['message', 'WARN']], "denies" => []},
|
47
|
+
%[
|
48
|
+
all deny
|
49
|
+
allow message: 'CRIT', message: 'WARN'
|
50
|
+
]],
|
51
|
+
"test values with comma" =>
|
52
|
+
[{"allows" => [['message', 'CRIT,'], ['message', 'WARN']], "denies" => []},
|
53
|
+
%[
|
54
|
+
all deny
|
55
|
+
allow message: 'CRIT,' % message: 'WARN'
|
56
|
+
delim %
|
57
|
+
]],
|
58
|
+
)
|
45
59
|
def test_configure(data)
|
46
60
|
expected, target = data
|
47
61
|
d = create_driver target
|
@@ -74,6 +74,23 @@ class Filter < Test::Unit::TestCase
|
|
74
74
|
assert_equal [['url', Regexp.new("\\/users\\/\\d+")]], d.instance.allows
|
75
75
|
assert_equal [], d.instance.denies
|
76
76
|
|
77
|
+
# text values
|
78
|
+
d = create_driver %[
|
79
|
+
all deny
|
80
|
+
allow message: 'CRIT', message: 'WARN'
|
81
|
+
]
|
82
|
+
assert_equal [['message', 'CRIT'], ['message', 'WARN']], d.instance.allows
|
83
|
+
assert_equal [], d.instance.denies
|
84
|
+
|
85
|
+
# test values with comma
|
86
|
+
d = create_driver %[
|
87
|
+
all deny
|
88
|
+
allow message: 'CRIT,' % message: 'WARN'
|
89
|
+
delim %
|
90
|
+
]
|
91
|
+
assert_equal [['message', 'CRIT,'], ['message', 'WARN']], d.instance.allows
|
92
|
+
assert_equal [], d.instance.denies
|
93
|
+
|
77
94
|
end
|
78
95
|
def test_emit
|
79
96
|
data = [
|
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.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muddy Dixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project: fluent-plugin-filter
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.2.2
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Simple output filter
|