fluent-plugin-filter 0.0.1 → 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 +7 -0
- data/.travis.yml +6 -0
- data/ChangeLog +7 -0
- data/README.rdoc +19 -0
- data/fluent-plugin-filter.gemspec +3 -2
- data/lib/fluent/plugin/out_filter.rb +6 -6
- data/test/plugin/test_out_filter.rb +54 -5
- metadata +37 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64a2e9dee2d826e3d964fa0d58d3cb33bd9ddef1
|
4
|
+
data.tar.gz: 313910f1c212e5c4f35b1146660a7b2056ffedf6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a223df306aedc58dbc2ee178b9acd0dbecc02780a62b4cc9cacbbb3aa56772bf853c6df60c3a5a667c5d4fc50d0131c6b33b6ccfd1cb94f748748d8b0ef811b1
|
7
|
+
data.tar.gz: dd3dc2d2184ad4ae9ceb74dd9f155700a631a70b0ead42339d9ca5615ba13a0714b748698fb05eb8cec4a7bbac5f03a6eee5e311c8816613d32e92fdebc3cc1b
|
data/.travis.yml
ADDED
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -42,6 +42,25 @@ 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
|
+
=== Parameters
|
46
|
+
|
47
|
+
==== all <allow|deny>
|
48
|
+
Specify basic policy.
|
49
|
+
|
50
|
+
==== allow field:<Pattern> / deny field:<Pattern>
|
51
|
+
Specify each field policies.
|
52
|
+
If a value for the field matches the pattern, the allow or deny rule is applied.
|
53
|
+
|
54
|
+
===== Pattern := <String|Integer|Float|Regexp>
|
55
|
+
|
56
|
+
Patten is parsed by following rules.
|
57
|
+
|
58
|
+
* Integer: a value consisted of degits without ".". e.g. status:200, price:10000
|
59
|
+
* Float: a value consisted of degits with "." (if you force the value float, set 200.0). e.g. average:145.0
|
60
|
+
* Regexp: a value starting with "/" and end with "/". e.g. path:/\/user\/\d+/
|
61
|
+
* thx @mmacvicar !
|
62
|
+
* String: a value unmatched below rule or enveloped with \" or \'.
|
63
|
+
|
45
64
|
== Contributing
|
46
65
|
|
47
66
|
1. Fork it
|
@@ -12,12 +12,13 @@ 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.0.3"
|
16
16
|
|
17
17
|
gem.extra_rdoc_files = [
|
18
18
|
"ChangeLog",
|
19
19
|
"README.rdoc"
|
20
|
-
]
|
20
|
+
]
|
21
|
+
gem.add_development_dependency "rake"
|
21
22
|
gem.add_development_dependency "fluentd"
|
22
23
|
gem.add_runtime_dependency "fluentd"
|
23
24
|
end
|
@@ -6,7 +6,7 @@ class FilterOutput < Output
|
|
6
6
|
config_param :allow, :string, :default => ''
|
7
7
|
config_param :deny, :string, :default => ''
|
8
8
|
config_param :add_prefix, :string, :default => 'filtered'
|
9
|
-
|
9
|
+
|
10
10
|
attr_accessor :allows
|
11
11
|
attr_accessor :denies
|
12
12
|
|
@@ -23,7 +23,7 @@ class FilterOutput < Output
|
|
23
23
|
v = v.to_i
|
24
24
|
elsif v =~ /^[\d\.]+(e\d+)?$/
|
25
25
|
v = v.to_f
|
26
|
-
elsif v =~ /^\/[^\/]+\/$/
|
26
|
+
elsif v =~ /^\/(\\\/|[^\/])+\/$/
|
27
27
|
v = Regexp.new(v.gsub(/^\/|\/$/, ''))
|
28
28
|
else
|
29
29
|
v = v.gsub(/^[\"\']|[\"\']$/, '')
|
@@ -35,9 +35,9 @@ class FilterOutput < Output
|
|
35
35
|
def passRules (record)
|
36
36
|
if @all == 'allow'
|
37
37
|
@denies.each do |deny|
|
38
|
-
if (deny[1].is_a? Regexp and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1]
|
38
|
+
if (deny[1].is_a? Regexp and record.has_key?(deny[0]) and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1]
|
39
39
|
@allows.each do |allow|
|
40
|
-
if (allow[1].is_a? Regexp and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1]
|
40
|
+
if (allow[1].is_a? Regexp and record.has_key?(allow[0]) and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1]
|
41
41
|
return true
|
42
42
|
end
|
43
43
|
end
|
@@ -47,9 +47,9 @@ class FilterOutput < Output
|
|
47
47
|
return true
|
48
48
|
else
|
49
49
|
@allows.each do |allow|
|
50
|
-
if (allow[1].is_a? Regexp and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1]
|
50
|
+
if (allow[1].is_a? Regexp and record.has_key?(allow[0]) and record[allow[0]].match(allow[1])) or record[allow[0]] == allow[1]
|
51
51
|
@denies.each do |deny|
|
52
|
-
if (deny[1].is_a? Regexp and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1]
|
52
|
+
if (deny[1].is_a? Regexp and record.has_key?(deny[0]) and record[deny[0]].match(deny[1])) or record[deny[0]] == deny[1]
|
53
53
|
return false
|
54
54
|
end
|
55
55
|
end
|
@@ -65,16 +65,24 @@ class Filter < Test::Unit::TestCase
|
|
65
65
|
]
|
66
66
|
assert_equal [['url', /hoge/]], d.instance.allows
|
67
67
|
assert_equal [], d.instance.denies
|
68
|
-
|
68
|
+
|
69
|
+
# regexp value with forward slashes
|
70
|
+
d = create_driver %[
|
71
|
+
all deny
|
72
|
+
allow url: /\\/users\\/\\d+/
|
73
|
+
]
|
74
|
+
assert_equal [['url', Regexp.new("\\/users\\/\\d+")]], d.instance.allows
|
75
|
+
assert_equal [], d.instance.denies
|
76
|
+
|
69
77
|
end
|
70
78
|
def test_emit
|
71
79
|
data = [
|
72
|
-
{'status' => 200, 'agent' => 'IE'},
|
80
|
+
{'status' => 200, 'agent' => 'IE', 'path' => '/users/1'},
|
73
81
|
{'status' => 303, 'agent' => 'Gecko'},
|
74
|
-
{'status' => 200, 'agent' => 'IE'},
|
82
|
+
{'status' => 200, 'agent' => 'IE', 'path' => '/users/2'},
|
75
83
|
{'status' => 401, 'agent' => 'Gecko'},
|
76
|
-
{'status' => 200, 'agent' => 'Gecka'},
|
77
|
-
{'status' => 404, 'agent' => 'Gecko'},
|
84
|
+
{'status' => 200, 'agent' => 'Gecka', 'path' => '/users/3'},
|
85
|
+
{'status' => 404, 'agent' => 'Gecko', 'path' => '/wrong'},
|
78
86
|
]
|
79
87
|
|
80
88
|
d = create_driver(CONFIG, 'test.input')
|
@@ -164,5 +172,46 @@ class Filter < Test::Unit::TestCase
|
|
164
172
|
end
|
165
173
|
assert_equal "hoge.test.input", d.emits[0][0]
|
166
174
|
|
175
|
+
d = create_driver(%[
|
176
|
+
all deny
|
177
|
+
allow path: /\\/users\\/\\d+/
|
178
|
+
], 'test.input')
|
179
|
+
|
180
|
+
d.run do
|
181
|
+
data.each do |dat|
|
182
|
+
d.emit dat
|
183
|
+
end
|
184
|
+
end
|
185
|
+
assert_equal 3, d.emits.length
|
186
|
+
|
187
|
+
data = [
|
188
|
+
{'message' => 'hoge', 'message2' => 'hoge2'},
|
189
|
+
{'message' => 'hoge3'},
|
190
|
+
]
|
191
|
+
|
192
|
+
d = create_driver(%[
|
193
|
+
all deny
|
194
|
+
allow message2: /hoge2/
|
195
|
+
], 'test.input')
|
196
|
+
|
197
|
+
d.run do
|
198
|
+
data.each do |dat|
|
199
|
+
d.emit dat
|
200
|
+
end
|
201
|
+
end
|
202
|
+
assert_equal 1, d.emits.length
|
203
|
+
|
204
|
+
d = create_driver(%[
|
205
|
+
all allow
|
206
|
+
deny message2: /hoge2/
|
207
|
+
], 'test.input')
|
208
|
+
|
209
|
+
d.run do
|
210
|
+
data.each do |dat|
|
211
|
+
d.emit dat
|
212
|
+
end
|
213
|
+
end
|
214
|
+
assert_equal 1, d.emits.length
|
215
|
+
|
167
216
|
end
|
168
217
|
end
|
metadata
CHANGED
@@ -1,38 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Muddy Dixon
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: fluentd
|
16
|
-
requirement:
|
17
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
18
30
|
requirements:
|
19
|
-
- -
|
31
|
+
- - '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
42
|
name: fluentd
|
27
|
-
requirement:
|
28
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
29
44
|
requirements:
|
30
|
-
- -
|
45
|
+
- - '>='
|
31
46
|
- !ruby/object:Gem::Version
|
32
47
|
version: '0'
|
33
48
|
type: :runtime
|
34
49
|
prerelease: false
|
35
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
36
55
|
description: Simple output filter
|
37
56
|
email:
|
38
57
|
- muddydixon@gmail.com
|
@@ -43,6 +62,7 @@ extra_rdoc_files:
|
|
43
62
|
- README.rdoc
|
44
63
|
files:
|
45
64
|
- .gitignore
|
65
|
+
- .travis.yml
|
46
66
|
- ChangeLog
|
47
67
|
- Gemfile
|
48
68
|
- LICENSE
|
@@ -55,28 +75,28 @@ files:
|
|
55
75
|
- test/plugin/test_out_filter.rb
|
56
76
|
homepage: https://github.com/muddydixon/fluent-plugin-filter
|
57
77
|
licenses: []
|
78
|
+
metadata: {}
|
58
79
|
post_install_message:
|
59
80
|
rdoc_options: []
|
60
81
|
require_paths:
|
61
82
|
- lib
|
62
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
84
|
requirements:
|
65
|
-
- -
|
85
|
+
- - '>='
|
66
86
|
- !ruby/object:Gem::Version
|
67
87
|
version: '0'
|
68
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
89
|
requirements:
|
71
|
-
- -
|
90
|
+
- - '>='
|
72
91
|
- !ruby/object:Gem::Version
|
73
92
|
version: '0'
|
74
93
|
requirements: []
|
75
94
|
rubyforge_project: fluent-plugin-filter
|
76
|
-
rubygems_version:
|
95
|
+
rubygems_version: 2.0.3
|
77
96
|
signing_key:
|
78
|
-
specification_version:
|
97
|
+
specification_version: 4
|
79
98
|
summary: Simple output filter
|
80
99
|
test_files:
|
81
100
|
- test/helper.rb
|
82
101
|
- test/plugin/test_out_filter.rb
|
102
|
+
has_rdoc:
|