fluent-plugin-grepcounter 0.3.1 → 0.4.0
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 +7 -0
- data/README.md +19 -11
- data/fluent-plugin-grepcounter.gemspec +1 -1
- data/lib/fluent/plugin/out_grepcounter.rb +14 -6
- data/spec/out_grepcounter_spec.rb +25 -5
- 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: 16a2bb7af97b5bbe3d7436c7f9ac749a74a8b660
|
4
|
+
data.tar.gz: 77e82589f64a366baf731899318c22c9cf076a37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c15035659a4ced1b00e033f8ab53e51cde287be5a62ef57af4834a75ba755eba6f929f4c3422534f368cb3842f83112fc70bb41a54eefc915b1534de7b284e
|
7
|
+
data.tar.gz: b67364cf3cd70c42bdd6015238383100d04fc030a320804a6c41eaa792ddd15be5335bfe37d1f7faf41ae1a41b3f12f3bfdea4d4d366fdc6cb6afaadb6af6a85
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.4.0 (2013/11/30)
|
2
|
+
|
3
|
+
Changes
|
4
|
+
|
5
|
+
- Change the option name `output_tag` to `tag`. `output_tag` is obsolete.
|
6
|
+
- Change the option name `output_with_joined_delimiter` to `delimiter`. `output_with_joined_delimiter` is obsolete.
|
7
|
+
|
1
8
|
## 0.3.1 (2013/11/02)
|
2
9
|
|
3
10
|
Changes
|
data/README.md
CHANGED
@@ -6,10 +6,10 @@ Fluentd plugin to count the number of matched messages, and emit if exeeds the `
|
|
6
6
|
|
7
7
|
Assume inputs from another plugin are as belows:
|
8
8
|
|
9
|
-
syslog.host1: {"message":"
|
10
|
-
syslog.host1: {"message":"
|
11
|
-
syslog.host1: {"message":"
|
12
|
-
syslog.host1: {"message":"
|
9
|
+
syslog.host1: {"message":"20.4.01/13T07:02:11.124202 INFO GET /ping" }
|
10
|
+
syslog.host1: {"message":"20.4.01/13T07:02:13.232645 WARN POST /auth" }
|
11
|
+
syslog.host1: {"message":"20.4.01/13T07:02:21.542145 WARN GET /favicon.ico" }
|
12
|
+
syslog.host1: {"message":"20.4.01/13T07:02:43.632145 WARN POST /login" }
|
13
13
|
|
14
14
|
An example of grepcounter configuration:
|
15
15
|
|
@@ -27,7 +27,7 @@ Then, output bocomes as belows (indented):
|
|
27
27
|
|
28
28
|
warn.count.syslog.host1: {
|
29
29
|
"count":2,
|
30
|
-
"message":["
|
30
|
+
"message":["20.4.01/13T07:02:13.232645 WARN POST /auth","20.4.01/13T07:02:43.632145 WARN POST /login"],
|
31
31
|
"input_tag":"syslog.host1",
|
32
32
|
"input_tag_last":"host1",
|
33
33
|
}
|
@@ -35,7 +35,7 @@ Then, output bocomes as belows (indented):
|
|
35
35
|
### output_with_joined_delimiter
|
36
36
|
|
37
37
|
As default, the `grepcounter` plugin outputs matched `message` as an array as shown above.
|
38
|
-
You may want to output `message` as a string, then use `
|
38
|
+
You may want to output `message` as a string, then use `delimiter` option like:
|
39
39
|
|
40
40
|
<match syslog.**>
|
41
41
|
type grepcounter
|
@@ -45,14 +45,14 @@ You may want to output `message` as a string, then use `output_with_joined_delim
|
|
45
45
|
exclude favicon.ico
|
46
46
|
threshold 1
|
47
47
|
add_tag_prefix warn.count
|
48
|
-
|
48
|
+
delimiter \n
|
49
49
|
</source>
|
50
50
|
|
51
51
|
Then, output bocomes as belows (indented). You can see the `message` field is joined with \n.
|
52
52
|
|
53
53
|
warn.count.syslog.host1: {
|
54
54
|
"count":2,
|
55
|
-
"message":"
|
55
|
+
"message":"20.4.01/13T07:02:13.232645 WARN POST /auth\n20.4.01/13T07:02:43.632145 WARN POST /login",
|
56
56
|
"input_tag":"syslog.host1",
|
57
57
|
"input_tag_last":"host1",
|
58
58
|
}
|
@@ -79,7 +79,7 @@ Then, output bocomes as belows (indented). You can see the `message` field is jo
|
|
79
79
|
|
80
80
|
The threshold number to emit. Emit if `count` value >= specified value.
|
81
81
|
|
82
|
-
- comparator (obsolete
|
82
|
+
- comparator (obsolete)
|
83
83
|
|
84
84
|
The comparation operator for the threshold (either of `>=` or `<=`). Default is `>=`, i.e., emit if count >= threshold.
|
85
85
|
NOTE: 0 count message will not be emitted even if `<=` is specified because standby nodes receive no message usually.
|
@@ -100,7 +100,11 @@ Then, output bocomes as belows (indented). You can see the `message` field is jo
|
|
100
100
|
|
101
101
|
Emit if `count` value is less than or equal to (<=) specified value.
|
102
102
|
|
103
|
-
- output\_tag
|
103
|
+
- output\_tag (obsolete from 0.4.0)
|
104
|
+
|
105
|
+
The output tag. Required for aggregate `all`.
|
106
|
+
|
107
|
+
- tag (from 0.4.0)
|
104
108
|
|
105
109
|
The output tag. Required for aggregate `all`.
|
106
110
|
|
@@ -108,7 +112,11 @@ Then, output bocomes as belows (indented). You can see the `message` field is jo
|
|
108
112
|
|
109
113
|
Add tag prefix for output message
|
110
114
|
|
111
|
-
- output\_with\_joined\_delimiter
|
115
|
+
- output\_with\_joined\_delimiter (obsolete from 0.4.0)
|
116
|
+
|
117
|
+
Output matched messages after `join`ed with the specified delimiter.
|
118
|
+
|
119
|
+
- delimiter (from 0.4.0)
|
112
120
|
|
113
121
|
Output matched messages after `join`ed with the specified delimiter.
|
114
122
|
|
@@ -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.
|
6
|
+
s.version = "0.4.0"
|
7
7
|
s.authors = ["Naotoshi SEO"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-grepcounter"
|
@@ -17,9 +17,11 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
17
17
|
config_param :less_equal, :float, :default => nil
|
18
18
|
config_param :greater_than, :float, :default => nil
|
19
19
|
config_param :greater_equal, :float, :default => nil
|
20
|
-
config_param :output_tag, :string, :default => nil
|
20
|
+
config_param :output_tag, :string, :default => nil # obsolete
|
21
|
+
config_param :tag, :string, :default => nil
|
21
22
|
config_param :add_tag_prefix, :string, :default => 'count'
|
22
|
-
config_param :output_with_joined_delimiter, :string, :default => nil
|
23
|
+
config_param :output_with_joined_delimiter, :string, :default => nil # obsolete
|
24
|
+
config_param :delimiter, :string, :default => nil
|
23
25
|
config_param :aggregate, :string, :default => 'tag'
|
24
26
|
config_param :replace_invalid_sequence, :bool, :default => false
|
25
27
|
config_param :store_file, :string, :default => nil
|
@@ -44,7 +46,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
44
46
|
raise Fluent::ConfigError, "grepcounter: comparator allows >=, <="
|
45
47
|
end
|
46
48
|
|
47
|
-
# to support obsolete options
|
49
|
+
# to support obsolete `threshold` and `comparator` options
|
48
50
|
if @threshold.nil? and @less_than.nil? and @less_equal.nil? and @greater_than.nil? and @greater_equal.nil?
|
49
51
|
@threshold = 1
|
50
52
|
end
|
@@ -56,6 +58,12 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
61
|
+
# to support osolete `output_tag` option
|
62
|
+
@tag = @output_tag if !@tag and @output_tag
|
63
|
+
|
64
|
+
# to support obsolete `output_with_joined_delimiter` option
|
65
|
+
@delimiter = @output_with_joined_delimiter if !@delimiter and @output_with_joined_delimiter
|
66
|
+
|
59
67
|
unless ['tag', 'all'].include?(@aggregate)
|
60
68
|
raise Fluent::ConfigError, "grepcounter: aggregate allows tag/all"
|
61
69
|
end
|
@@ -145,13 +153,13 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
145
153
|
matches += flushed_matches[tag]
|
146
154
|
end
|
147
155
|
output = generate_output(count, matches)
|
148
|
-
Fluent::Engine.emit(@
|
156
|
+
Fluent::Engine.emit(@tag, time, output) if output
|
149
157
|
else
|
150
158
|
flushed_counts.keys.each do |tag|
|
151
159
|
count = flushed_counts[tag]
|
152
160
|
matches = flushed_matches[tag]
|
153
161
|
output = generate_output(count, matches, tag)
|
154
|
-
tag = @
|
162
|
+
tag = @tag ? @tag : "#{@add_tag_prefix}.#{tag}"
|
155
163
|
Fluent::Engine.emit(tag, time, output) if output
|
156
164
|
end
|
157
165
|
end
|
@@ -166,7 +174,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
166
174
|
return nil if @greater_equal and count < @greater_equal
|
167
175
|
output = {}
|
168
176
|
output['count'] = count
|
169
|
-
output['message'] = @
|
177
|
+
output['message'] = @delimiter.nil? ? matches : matches.join(@delimiter)
|
170
178
|
if tag
|
171
179
|
output['input_tag'] = tag
|
172
180
|
output['input_tag_last'] = tag.split('.').last
|
@@ -50,7 +50,7 @@ describe Fluent::GrepCounterOutput do
|
|
50
50
|
its(:exclude) { should be_nil }
|
51
51
|
its(:threshold) { should == 1 }
|
52
52
|
its(:comparator) { should == '>=' }
|
53
|
-
its(:
|
53
|
+
its(:tag) { should be_nil }
|
54
54
|
its(:add_tag_prefix) { should == 'count' }
|
55
55
|
end
|
56
56
|
end
|
@@ -124,7 +124,7 @@ describe Fluent::GrepCounterOutput do
|
|
124
124
|
it { emit }
|
125
125
|
end
|
126
126
|
|
127
|
-
context "threshold and comparator" do
|
127
|
+
context "threshold and comparator (obsolete)" do
|
128
128
|
context '>= threshold' do
|
129
129
|
let(:config) { CONFIG + %[threshold 4] }
|
130
130
|
before do
|
@@ -162,7 +162,7 @@ describe Fluent::GrepCounterOutput do
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
context "less
|
165
|
+
context "less and greater" do
|
166
166
|
context 'greater_equal' do
|
167
167
|
let(:config) { CONFIG + %[greater_equal 4] }
|
168
168
|
before do
|
@@ -254,7 +254,7 @@ describe Fluent::GrepCounterOutput do
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
-
context 'output_tag' do
|
257
|
+
context 'output_tag (obsolete)' do
|
258
258
|
let(:config) { CONFIG + %[output_tag foo] }
|
259
259
|
before do
|
260
260
|
Fluent::Engine.stub(:now).and_return(time)
|
@@ -263,6 +263,15 @@ describe Fluent::GrepCounterOutput do
|
|
263
263
|
it { emit }
|
264
264
|
end
|
265
265
|
|
266
|
+
context 'tag' do
|
267
|
+
let(:config) { CONFIG + %[tag foo] }
|
268
|
+
before do
|
269
|
+
Fluent::Engine.stub(:now).and_return(time)
|
270
|
+
Fluent::Engine.should_receive(:emit).with("foo", time, expected)
|
271
|
+
end
|
272
|
+
it { emit }
|
273
|
+
end
|
274
|
+
|
266
275
|
context 'add_tag_prefix' do
|
267
276
|
let(:config) { CONFIG + %[add_tag_prefix foo] }
|
268
277
|
before do
|
@@ -272,7 +281,7 @@ describe Fluent::GrepCounterOutput do
|
|
272
281
|
it { emit }
|
273
282
|
end
|
274
283
|
|
275
|
-
context 'output_with_joined_delimiter' do
|
284
|
+
context 'output_with_joined_delimiter (obsolete)' do
|
276
285
|
# \\n shall be \n in config file
|
277
286
|
let(:config) { CONFIG + %[output_with_joined_delimiter \\n] }
|
278
287
|
before do
|
@@ -283,6 +292,17 @@ describe Fluent::GrepCounterOutput do
|
|
283
292
|
it { emit }
|
284
293
|
end
|
285
294
|
|
295
|
+
context 'delimiter' do
|
296
|
+
# \\n shall be \n in config file
|
297
|
+
let(:config) { CONFIG + %[delimiter \\n] }
|
298
|
+
before do
|
299
|
+
Fluent::Engine.stub(:now).and_return(time)
|
300
|
+
message = expected["message"].join('\n')
|
301
|
+
Fluent::Engine.should_receive(:emit).with("count.#{tag}", time, expected.merge("message" => message))
|
302
|
+
end
|
303
|
+
it { emit }
|
304
|
+
end
|
305
|
+
|
286
306
|
context 'aggregate all' do
|
287
307
|
let(:messages) { ['foobar', 'foobar'] }
|
288
308
|
let(:emit) do
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi SEO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|