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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 215960b8db1dca534d808e0913b522ca527c6457
4
- data.tar.gz: 81761e8e0861c39afa42fe64dd50e3cab426d63b
3
+ metadata.gz: be8cf5ff3ab2e36b58ddea36e60630cb2e4a337d
4
+ data.tar.gz: 3ac6af56a55b316e3e889763e962a2df39517cec
5
5
  SHA512:
6
- metadata.gz: 087f920ff64c50ae1e6f299b6fa7d09d787e507895a3d4b640d4d653e84fd5b9dea01454dd0c2324014e8d3109fc2462e404961bef4f27e63a57afeb57c1edbb
7
- data.tar.gz: c7e1bc599c28d15f4e9283bb91229dc95b05e6317b845798e90fc5ef0f16f307d587365d5c8d8e969a5bc2cb12621e2170df8865edd860351934d45efbcdd69a
6
+ metadata.gz: d9d5e44650f926f86e45445dc3a9eddc6d5f758f3089ef2e09e1907bb7acf6fe1efe33b5a43f829269cc124d296092dbff87c5536507d46d1b3b9a89537f1013
7
+ data.tar.gz: 7a5b25fee4361ffdd08958d8ac1b20abec0d00e5c97873332c7e6ed10d96e59f9ee25400938ffd7262feb0f8b6a89a4fd440c553953248594952a3fdec4d0968
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
2
  - 2.1
3
+ - 2.2
5
4
  gemfile:
6
5
  - Gemfile
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>
@@ -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.4"
15
+ gem.version = "0.0.5"
16
16
 
17
17
  gem.extra_rdoc_files = [
18
18
  "ChangeLog",
@@ -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)
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module FilterUtil
3
- def toMap (str)
4
- str.split(/\s*,\s*/).map do|pair|
3
+ def toMap (str, delim)
4
+ str.split(/\s*#{delim}\s*/).map do|pair|
5
5
  k, v = pair.split(/\s*:\s*/, 2)
6
6
  if v =~ /^\d+$/
7
7
  v = v.to_i
@@ -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
- Engine.emit(tag, time, record)
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
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-05-17 00:00:00.000000000 Z
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.4.5
98
+ rubygems_version: 2.2.2
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: Simple output filter