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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +10 -2
- data/fluent-plugin-grepcounter.gemspec +1 -1
- data/lib/fluent/plugin/out_grepcounter.rb +15 -7
- data/spec/out_grepcounter_spec.rb +37 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02fcfc4239d3f9c72ad1831c502ffa09c71552f8
|
4
|
+
data.tar.gz: e341d89ebae652e888159f2e830c4ed3252dcc3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 530e25bea4620fe5798183dbb48d3c1a8a5b760fc05f28fed0bba103392ab65d02e19922946fc8b920945f069368cd0e6388885dd993dc8d77a389ed1171280a
|
7
|
+
data.tar.gz: cf539ce20180ab51363a4e5f03cd46179b2530322f3d1f553cbd9e9942acda61eb307ae0a1f15407021765eee34fec55855b4877b67ea8b07601ecc4eaa84e32
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
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
|
-
</
|
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
|
-
</
|
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.
|
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 @
|
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 @
|
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.
|
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-
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|