fluent-plugin-grepcounter 0.5.3 → 0.5.4
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/CHANGELOG.md +6 -0
- data/fluent-plugin-grepcounter.gemspec +1 -1
- data/lib/fluent/plugin/out_grepcounter.rb +20 -22
- data/spec/out_grepcounter_spec.rb +40 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90eca84d0b796ebd73afe0413d519a7d5d0517ec
|
4
|
+
data.tar.gz: 39accc620e237df5075a40d8c752535df1c9c989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fc4b7c068508e720d119c8ce7ed41c1b686259aac99bdaa44dd3e1ecfb0274f92eb6371eab2aee7cef510a437aa5c65f0ecd9c6469af5d53965f9b1d6e0c01
|
7
|
+
data.tar.gz: fdf50b8f80388238581370f1491a967af796f2cd4dcebaca5be2a0293157a72d5b7098d4d36369193567843740ae8d42b8d8a552706deeaf21716f35ddb89e2e
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
6
|
+
s.version = "0.5.4"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-grepcounter"
|
@@ -97,22 +97,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
97
97
|
if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil?
|
98
98
|
@add_tag_prefix = 'count' # not ConfigError to support lower version compatibility
|
99
99
|
end
|
100
|
-
@
|
101
|
-
@tag_suffix = ".#{@add_tag_suffix}" if @add_tag_suffix
|
102
|
-
@tag_prefix_match = "#{@remove_tag_prefix}." if @remove_tag_prefix
|
103
|
-
@tag_suffix_match = ".#{@remove_tag_suffix}" if @remove_tag_suffix
|
104
|
-
@tag_proc =
|
105
|
-
if @tag
|
106
|
-
Proc.new {|tag| @tag }
|
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}" }
|
109
|
-
elsif @tag_prefix_match
|
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}" }
|
113
|
-
else
|
114
|
-
Proc.new {|tag| "#{@tag_prefix}#{tag}#{@tag_suffix}" }
|
115
|
-
end
|
100
|
+
@tag_proc = tag_proc
|
116
101
|
|
117
102
|
case @aggregate
|
118
103
|
when 'all'
|
@@ -249,12 +234,25 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
249
234
|
output
|
250
235
|
end
|
251
236
|
|
252
|
-
def
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
237
|
+
def tag_proc
|
238
|
+
rstrip = Proc.new {|str, substr| str.chomp(substr) }
|
239
|
+
lstrip = Proc.new {|str, substr| str.start_with?(substr) ? str[substr.size..-1] : str }
|
240
|
+
tag_prefix = "#{rstrip.call(@add_tag_prefix, '.')}." if @add_tag_prefix
|
241
|
+
tag_suffix = ".#{lstrip.call(@add_tag_suffix, '.')}" if @add_tag_suffix
|
242
|
+
tag_prefix_match = "#{rstrip.call(@remove_tag_prefix, '.')}." if @remove_tag_prefix
|
243
|
+
tag_suffix_match = ".#{lstrip.call(@remove_tag_suffix, '.')}" if @remove_tag_suffix
|
244
|
+
tag_fixed = @tag if @tag
|
245
|
+
if tag_fixed
|
246
|
+
Proc.new {|tag| tag_fixed }
|
247
|
+
elsif tag_prefix_match and tag_suffix_match
|
248
|
+
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(lstrip.call(tag, tag_prefix_match), tag_suffix_match)}#{tag_suffix}" }
|
249
|
+
elsif tag_prefix_match
|
250
|
+
Proc.new {|tag| "#{tag_prefix}#{lstrip.call(tag, tag_prefix_match)}#{tag_suffix}" }
|
251
|
+
elsif tag_suffix_match
|
252
|
+
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(tag, tag_suffix_match)}#{tag_suffix}" }
|
253
|
+
else
|
254
|
+
Proc.new {|tag| "#{tag_prefix}#{tag}#{tag_suffix}" }
|
255
|
+
end
|
258
256
|
end
|
259
257
|
|
260
258
|
def match(regexp, string)
|
@@ -355,6 +355,46 @@ describe Fluent::GrepCounterOutput do
|
|
355
355
|
it { emit }
|
356
356
|
end
|
357
357
|
|
358
|
+
context 'add_tag_prefix.' do
|
359
|
+
let(:config) { CONFIG + %[add_tag_prefix foo.] }
|
360
|
+
let(:tag) { 'syslog.host1' }
|
361
|
+
before do
|
362
|
+
Fluent::Engine.stub(:now).and_return(time)
|
363
|
+
Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
|
364
|
+
end
|
365
|
+
it { emit }
|
366
|
+
end
|
367
|
+
|
368
|
+
context 'remove_tag_prefix.' do
|
369
|
+
let(:config) { CONFIG + %[remove_tag_prefix syslog.] }
|
370
|
+
let(:tag) { 'syslog.host1' }
|
371
|
+
before do
|
372
|
+
Fluent::Engine.stub(:now).and_return(time)
|
373
|
+
Fluent::Engine.should_receive(:emit).with("host1", time, expected)
|
374
|
+
end
|
375
|
+
it { emit }
|
376
|
+
end
|
377
|
+
|
378
|
+
context '.add_tag_suffix' do
|
379
|
+
let(:config) { CONFIG + %[add_tag_suffix .foo] }
|
380
|
+
let(:tag) { 'syslog.host1' }
|
381
|
+
before do
|
382
|
+
Fluent::Engine.stub(:now).and_return(time)
|
383
|
+
Fluent::Engine.should_receive(:emit).with("#{tag}.foo", time, expected)
|
384
|
+
end
|
385
|
+
it { emit }
|
386
|
+
end
|
387
|
+
|
388
|
+
context '.remove_tag_suffix' do
|
389
|
+
let(:config) { CONFIG + %[remove_tag_suffix .host1] }
|
390
|
+
let(:tag) { 'syslog.host1' }
|
391
|
+
before do
|
392
|
+
Fluent::Engine.stub(:now).and_return(time)
|
393
|
+
Fluent::Engine.should_receive(:emit).with("syslog", time, expected)
|
394
|
+
end
|
395
|
+
it { emit }
|
396
|
+
end
|
397
|
+
|
358
398
|
context 'output_with_joined_delimiter (obsolete)' do
|
359
399
|
# \\n shall be \n in config file
|
360
400
|
let(:config) { CONFIG + %[output_with_joined_delimiter \\n] }
|