fluent-plugin-grepcounter 0.5.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a3f68aa7d961b029edcb310440dafcc74f4e27c
4
- data.tar.gz: 685ed1187c0349c9980077cf843e8cdd37627973
3
+ metadata.gz: 02fcfc4239d3f9c72ad1831c502ffa09c71552f8
4
+ data.tar.gz: e341d89ebae652e888159f2e830c4ed3252dcc3d
5
5
  SHA512:
6
- metadata.gz: 2bd4ac357031dae5ab89d58e1ed35c90722cfa0fb2f64aab213a4c6d286956bea5bb0ef58a081eccf7bee797dd89a05738ceb26a25802cb1766650e83c57d926
7
- data.tar.gz: 52505feb90d47a807b645e86fbce71c3383faec26d0a01d1832c462ab4b8886b297d607a78d7d20b2d0732107d824558eb684a1f953b1b837d1d790742362080
6
+ metadata.gz: 530e25bea4620fe5798183dbb48d3c1a8a5b760fc05f28fed0bba103392ab65d02e19922946fc8b920945f069368cd0e6388885dd993dc8d77a389ed1171280a
7
+ data.tar.gz: cf539ce20180ab51363a4e5f03cd46179b2530322f3d1f553cbd9e9942acda61eb307ae0a1f15407021765eee34fec55855b4877b67ea8b07601ecc4eaa84e32
@@ -1,6 +1,6 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
4
3
  - 2.0.0
4
+ - 2.1.*
5
5
  gemfile:
6
6
  - Gemfile
@@ -1,3 +1,9 @@
1
+ ## 0.5.3 (2014/04/11)
2
+
3
+ Enhancement:
4
+
5
+ * Add `add_tag_suffix` and `remove_tag_suffix` options
6
+
1
7
  ## 0.5.2 (2014/02/04)
2
8
 
3
9
  Enhancement:
data/README.md CHANGED
@@ -21,7 +21,7 @@ An example of grepcounter configuration:
21
21
  exclude favicon.ico
22
22
  threshold 1
23
23
  add_tag_prefix warn.count
24
- </source>
24
+ </match>
25
25
 
26
26
  Then, output bocomes as belows (indented):
27
27
 
@@ -46,7 +46,7 @@ You may want to output `message` as a string, then use `delimiter` option like:
46
46
  threshold 1
47
47
  add_tag_prefix warn.count
48
48
  delimiter \n
49
- </source>
49
+ </match>
50
50
 
51
51
  Then, output bocomes as belows (indented). You can see the `message` field is joined with \n.
52
52
 
@@ -115,6 +115,14 @@ Then, output bocomes as belows (indented). You can see the `message` field is jo
115
115
 
116
116
  Remove tag prefix for output message
117
117
 
118
+ - add\_tag\_suffix
119
+
120
+ Add tag suffix for output message
121
+
122
+ - remove\_tag\_suffix
123
+
124
+ Remove tag suffix for output message
125
+
118
126
  - delimiter
119
127
 
120
128
  Output matched messages after `join`ed with the specified delimiter.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-grepcounter"
6
- s.version = "0.5.2"
6
+ s.version = "0.5.3"
7
7
  s.authors = ["Naotoshi Seo"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-grepcounter"
@@ -30,6 +30,8 @@ class Fluent::GrepCounterOutput < Fluent::Output
30
30
  config_param :tag, :string, :default => nil
31
31
  config_param :add_tag_prefix, :string, :default => nil
32
32
  config_param :remove_tag_prefix, :string, :default => nil
33
+ config_param :add_tag_suffix, :string, :default => nil
34
+ config_param :remove_tag_suffix, :string, :default => nil
33
35
  config_param :output_with_joined_delimiter, :string, :default => nil # obsolete
34
36
  config_param :delimiter, :string, :default => nil
35
37
  config_param :aggregate, :string, :default => 'tag'
@@ -92,22 +94,24 @@ class Fluent::GrepCounterOutput < Fluent::Output
92
94
  end
93
95
  end
94
96
 
95
- if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil?
97
+ if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil?
96
98
  @add_tag_prefix = 'count' # not ConfigError to support lower version compatibility
97
99
  end
98
100
  @tag_prefix = "#{@add_tag_prefix}." if @add_tag_prefix
101
+ @tag_suffix = ".#{@add_tag_suffix}" if @add_tag_suffix
99
102
  @tag_prefix_match = "#{@remove_tag_prefix}." if @remove_tag_prefix
103
+ @tag_suffix_match = ".#{@remove_tag_suffix}" if @remove_tag_suffix
100
104
  @tag_proc =
101
105
  if @tag
102
106
  Proc.new {|tag| @tag }
103
- elsif @tag_prefix and @tag_prefix_match
104
- Proc.new {|tag| "#{@tag_prefix}#{lstrip(tag, @tag_prefix_match)}" }
107
+ elsif @tag_prefix_match and @tag_suffix_match
108
+ Proc.new {|tag| "#{@tag_prefix}#{rstrip(lstrip(tag, @tag_prefix_match), @tag_suffix_match)}#{@tag_suffix}" }
105
109
  elsif @tag_prefix_match
106
- Proc.new {|tag| lstrip(tag, @tag_prefix_match) }
107
- elsif @tag_prefix
108
- Proc.new {|tag| "#{@tag_prefix}#{tag}" }
110
+ Proc.new {|tag| "#{@tag_prefix}#{lstrip(tag, @tag_prefix_match)}#{@tag_suffix}" }
111
+ elsif @tag_suffix_match
112
+ Proc.new {|tag| "#{@tag_prefix}#{rstrip(tag, @tag_suffix_match)}#{@tag_suffix}" }
109
113
  else
110
- Proc.new {|tag| tag }
114
+ Proc.new {|tag| "#{@tag_prefix}#{tag}#{@tag_suffix}" }
111
115
  end
112
116
 
113
117
  case @aggregate
@@ -245,6 +249,10 @@ class Fluent::GrepCounterOutput < Fluent::Output
245
249
  output
246
250
  end
247
251
 
252
+ def rstrip(string, substring)
253
+ string.chomp(substring)
254
+ end
255
+
248
256
  def lstrip(string, substring)
249
257
  string.index(substring) == 0 ? string[substring.size..-1] : string
250
258
  end
@@ -302,6 +302,7 @@ describe Fluent::GrepCounterOutput do
302
302
 
303
303
  context 'add_tag_prefix' do
304
304
  let(:config) { CONFIG + %[add_tag_prefix foo] }
305
+ let(:tag) { 'syslog.host1' }
305
306
  before do
306
307
  Fluent::Engine.stub(:now).and_return(time)
307
308
  Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
@@ -311,6 +312,7 @@ describe Fluent::GrepCounterOutput do
311
312
 
312
313
  context 'remove_tag_prefix' do
313
314
  let(:config) { CONFIG + %[remove_tag_prefix syslog] }
315
+ let(:tag) { 'syslog.host1' }
314
316
  before do
315
317
  Fluent::Engine.stub(:now).and_return(time)
316
318
  Fluent::Engine.should_receive(:emit).with("host1", time, expected)
@@ -318,6 +320,41 @@ describe Fluent::GrepCounterOutput do
318
320
  it { emit }
319
321
  end
320
322
 
323
+ context 'add_tag_suffix' do
324
+ let(:config) { CONFIG + %[add_tag_suffix foo] }
325
+ let(:tag) { 'syslog.host1' }
326
+ before do
327
+ Fluent::Engine.stub(:now).and_return(time)
328
+ Fluent::Engine.should_receive(:emit).with("#{tag}.foo", time, expected)
329
+ end
330
+ it { emit }
331
+ end
332
+
333
+ context 'remove_tag_suffix' do
334
+ let(:config) { CONFIG + %[remove_tag_suffix host1] }
335
+ let(:tag) { 'syslog.host1' }
336
+ before do
337
+ Fluent::Engine.stub(:now).and_return(time)
338
+ Fluent::Engine.should_receive(:emit).with("syslog", time, expected)
339
+ end
340
+ it { emit }
341
+ end
342
+
343
+ context 'all tag options' do
344
+ let(:config) { CONFIG + %[
345
+ add_tag_prefix foo
346
+ add_tag_suffix foo
347
+ remove_tag_prefix syslog
348
+ remove_tag_suffix host1
349
+ ]}
350
+ let(:tag) { 'syslog.foo.host1' }
351
+ before do
352
+ Fluent::Engine.stub(:now).and_return(time)
353
+ Fluent::Engine.should_receive(:emit).with("foo.foo.foo", time, expected)
354
+ end
355
+ it { emit }
356
+ end
357
+
321
358
  context 'output_with_joined_delimiter (obsolete)' do
322
359
  # \\n shall be \n in config file
323
360
  let(:config) { CONFIG + %[output_with_joined_delimiter \\n] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-grepcounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd