fluent-plugin-grepcounter 0.5.5 → 0.5.6
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 +9 -4
- data/spec/out_grepcounter_spec.rb +37 -37
- 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: f187009dead1522e4bef22b7a505085d271ee46c
|
4
|
+
data.tar.gz: ff997a2771fa6e16a5fa6f44758d0a46d59cbeeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa074c1989f4117b55a5e656d7e1290e8e60dfe9ce55c97c007da627bea24bf4690256413c6bac5d688a9c585b1d9b3f65a421b568a6ccd1b8784460cf9d944
|
7
|
+
data.tar.gz: 12d5df257832eb73754849bc9b0acc95a0834cc05b4ab32ed0f996ad6732525daf2971dbbb4074734c987b8e3b9340ff0691dba9d0cb34c6a69316b432954296
|
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.6"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-grepcounter"
|
@@ -7,6 +7,11 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
7
7
|
define_method("log") { $log }
|
8
8
|
end
|
9
9
|
|
10
|
+
# Define `router` method of v0.12 to support v0.10 or earlier
|
11
|
+
unless method_defined?(:router)
|
12
|
+
define_method("router") { Fluent::Engine }
|
13
|
+
end
|
14
|
+
|
10
15
|
REGEXP_MAX_NUM = 20
|
11
16
|
|
12
17
|
def initialize
|
@@ -95,7 +100,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
98
|
-
if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil? and @remove_tag_slice.nil?
|
103
|
+
if conf['@label'].nil? and @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil? and @remove_tag_slice.nil?
|
99
104
|
@add_tag_prefix = 'count' # not ConfigError to support lower version compatibility
|
100
105
|
end
|
101
106
|
@tag_proc = tag_proc
|
@@ -203,14 +208,14 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
203
208
|
count = flushed_counts[:all]
|
204
209
|
matches = flushed_matches[:all]
|
205
210
|
output = generate_output(count, matches)
|
206
|
-
|
211
|
+
router.emit(@tag, time, output) if output
|
207
212
|
when 'out_tag'
|
208
213
|
flushed_counts.keys.each do |out_tag|
|
209
214
|
count = flushed_counts[out_tag]
|
210
215
|
matches = flushed_matches[out_tag]
|
211
216
|
output = generate_output(count, matches)
|
212
217
|
if output
|
213
|
-
|
218
|
+
router.emit(out_tag, time, output)
|
214
219
|
end
|
215
220
|
end
|
216
221
|
else # in_tag
|
@@ -220,7 +225,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
220
225
|
output = generate_output(count, matches, tag)
|
221
226
|
if output
|
222
227
|
out_tag = @tag_proc.call(tag)
|
223
|
-
|
228
|
+
router.emit(out_tag, time, output)
|
224
229
|
end
|
225
230
|
end
|
226
231
|
end
|
@@ -94,7 +94,7 @@ describe Fluent::GrepCounterOutput do
|
|
94
94
|
let(:config) { CONFIG }
|
95
95
|
before do
|
96
96
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
97
|
-
expect(
|
97
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
98
98
|
end
|
99
99
|
it { emit }
|
100
100
|
end
|
@@ -103,7 +103,7 @@ describe Fluent::GrepCounterOutput do
|
|
103
103
|
let(:config) { CONFIG + %[ regexp WARN ] }
|
104
104
|
before do
|
105
105
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
106
|
-
expect(
|
106
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge({
|
107
107
|
"count"=>3,
|
108
108
|
"message"=>[
|
109
109
|
"2013/01/13T07:02:13.232645 WARN POST /auth",
|
@@ -119,7 +119,7 @@ describe Fluent::GrepCounterOutput do
|
|
119
119
|
let(:config) { %[ regexp1 message WARN ] }
|
120
120
|
before do
|
121
121
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
122
|
-
expect(
|
122
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge({
|
123
123
|
"count"=>3,
|
124
124
|
}).delete!('message'))
|
125
125
|
end
|
@@ -130,7 +130,7 @@ describe Fluent::GrepCounterOutput do
|
|
130
130
|
let(:config) { CONFIG + %[regexp WARN \n exclude favicon] }
|
131
131
|
before do
|
132
132
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
133
|
-
expect(
|
133
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge({
|
134
134
|
"count"=>2,
|
135
135
|
"message"=>[
|
136
136
|
"2013/01/13T07:02:13.232645 WARN POST /auth",
|
@@ -145,7 +145,7 @@ describe Fluent::GrepCounterOutput do
|
|
145
145
|
let(:config) { %[regexp1 message WARN \n exclude1 message favicon] }
|
146
146
|
before do
|
147
147
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
148
|
-
expect(
|
148
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge({
|
149
149
|
"count"=>2,
|
150
150
|
}).delete!('message'))
|
151
151
|
end
|
@@ -157,7 +157,7 @@ describe Fluent::GrepCounterOutput do
|
|
157
157
|
let(:config) { CONFIG + %[threshold 4] }
|
158
158
|
before do
|
159
159
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
160
|
-
expect(
|
160
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
161
161
|
end
|
162
162
|
it { emit }
|
163
163
|
end
|
@@ -166,7 +166,7 @@ describe Fluent::GrepCounterOutput do
|
|
166
166
|
let(:config) { CONFIG + %[threshold 5] }
|
167
167
|
before do
|
168
168
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
169
|
-
expect(
|
169
|
+
expect(driver.instance.router).not_to receive(:emit)
|
170
170
|
end
|
171
171
|
it { emit }
|
172
172
|
end
|
@@ -175,7 +175,7 @@ describe Fluent::GrepCounterOutput do
|
|
175
175
|
let(:config) { CONFIG + %[threshold 4 \n comparator <=] }
|
176
176
|
before do
|
177
177
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
178
|
-
expect(
|
178
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
179
179
|
end
|
180
180
|
it { emit }
|
181
181
|
end
|
@@ -184,7 +184,7 @@ describe Fluent::GrepCounterOutput do
|
|
184
184
|
let(:config) { CONFIG + %[threshold 3 \n comparator <=] }
|
185
185
|
before do
|
186
186
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
187
|
-
expect(
|
187
|
+
expect(driver.instance.router).not_to receive(:emit)
|
188
188
|
end
|
189
189
|
it { emit }
|
190
190
|
end
|
@@ -195,7 +195,7 @@ describe Fluent::GrepCounterOutput do
|
|
195
195
|
let(:config) { CONFIG + %[greater_equal 4] }
|
196
196
|
before do
|
197
197
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
198
|
-
expect(
|
198
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
199
199
|
end
|
200
200
|
it { emit }
|
201
201
|
end
|
@@ -204,7 +204,7 @@ describe Fluent::GrepCounterOutput do
|
|
204
204
|
let(:config) { CONFIG + %[greater_equal 5] }
|
205
205
|
before do
|
206
206
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
207
|
-
expect(
|
207
|
+
expect(driver.instance.router).not_to receive(:emit)
|
208
208
|
end
|
209
209
|
it { emit }
|
210
210
|
end
|
@@ -213,7 +213,7 @@ describe Fluent::GrepCounterOutput do
|
|
213
213
|
let(:config) { CONFIG + %[greater_than 3] }
|
214
214
|
before do
|
215
215
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
216
|
-
expect(
|
216
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
217
217
|
end
|
218
218
|
it { emit }
|
219
219
|
end
|
@@ -222,7 +222,7 @@ describe Fluent::GrepCounterOutput do
|
|
222
222
|
let(:config) { CONFIG + %[greater_than 4] }
|
223
223
|
before do
|
224
224
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
225
|
-
expect(
|
225
|
+
expect(driver.instance.router).not_to receive(:emit)
|
226
226
|
end
|
227
227
|
it { emit }
|
228
228
|
end
|
@@ -231,7 +231,7 @@ describe Fluent::GrepCounterOutput do
|
|
231
231
|
let(:config) { CONFIG + %[less_equal 4] }
|
232
232
|
before do
|
233
233
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
234
|
-
expect(
|
234
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
235
235
|
end
|
236
236
|
it { emit }
|
237
237
|
end
|
@@ -240,7 +240,7 @@ describe Fluent::GrepCounterOutput do
|
|
240
240
|
let(:config) { CONFIG + %[less_equal 3] }
|
241
241
|
before do
|
242
242
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
243
|
-
expect(
|
243
|
+
expect(driver.instance.router).not_to receive(:emit)
|
244
244
|
end
|
245
245
|
it { emit }
|
246
246
|
end
|
@@ -249,7 +249,7 @@ describe Fluent::GrepCounterOutput do
|
|
249
249
|
let(:config) { CONFIG + %[less_than 5] }
|
250
250
|
before do
|
251
251
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
252
|
-
expect(
|
252
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
253
253
|
end
|
254
254
|
it { emit }
|
255
255
|
end
|
@@ -258,7 +258,7 @@ describe Fluent::GrepCounterOutput do
|
|
258
258
|
let(:config) { CONFIG + %[less_than 4] }
|
259
259
|
before do
|
260
260
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
261
|
-
expect(
|
261
|
+
expect(driver.instance.router).not_to receive(:emit)
|
262
262
|
end
|
263
263
|
it { emit }
|
264
264
|
end
|
@@ -267,7 +267,7 @@ describe Fluent::GrepCounterOutput do
|
|
267
267
|
let(:config) { CONFIG + %[greater_than 1 \n less_than 5] }
|
268
268
|
before do
|
269
269
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
270
|
-
expect(
|
270
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected)
|
271
271
|
end
|
272
272
|
it { emit }
|
273
273
|
end
|
@@ -276,7 +276,7 @@ describe Fluent::GrepCounterOutput do
|
|
276
276
|
let(:config) { CONFIG + %[greater_than 1 \n less_than 4] }
|
277
277
|
before do
|
278
278
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
279
|
-
expect(
|
279
|
+
expect(driver.instance.router).not_to receive(:emit)
|
280
280
|
end
|
281
281
|
it { emit }
|
282
282
|
end
|
@@ -286,7 +286,7 @@ describe Fluent::GrepCounterOutput do
|
|
286
286
|
let(:config) { CONFIG + %[output_tag foo] }
|
287
287
|
before do
|
288
288
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
289
|
-
expect(
|
289
|
+
expect(driver.instance.router).to receive(:emit).with("foo", time, expected)
|
290
290
|
end
|
291
291
|
it { emit }
|
292
292
|
end
|
@@ -295,7 +295,7 @@ describe Fluent::GrepCounterOutput do
|
|
295
295
|
let(:config) { CONFIG + %[tag foo] }
|
296
296
|
before do
|
297
297
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
298
|
-
expect(
|
298
|
+
expect(driver.instance.router).to receive(:emit).with("foo", time, expected)
|
299
299
|
end
|
300
300
|
it { emit }
|
301
301
|
end
|
@@ -305,7 +305,7 @@ describe Fluent::GrepCounterOutput do
|
|
305
305
|
let(:tag) { 'syslog.host1' }
|
306
306
|
before do
|
307
307
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
308
|
-
expect(
|
308
|
+
expect(driver.instance.router).to receive(:emit).with("foo.#{tag}", time, expected)
|
309
309
|
end
|
310
310
|
it { emit }
|
311
311
|
end
|
@@ -315,7 +315,7 @@ describe Fluent::GrepCounterOutput do
|
|
315
315
|
let(:tag) { 'syslog.host1' }
|
316
316
|
before do
|
317
317
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
318
|
-
expect(
|
318
|
+
expect(driver.instance.router).to receive(:emit).with("host1", time, expected)
|
319
319
|
end
|
320
320
|
it { emit }
|
321
321
|
end
|
@@ -325,7 +325,7 @@ describe Fluent::GrepCounterOutput do
|
|
325
325
|
let(:tag) { 'syslog.host1' }
|
326
326
|
before do
|
327
327
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
328
|
-
expect(
|
328
|
+
expect(driver.instance.router).to receive(:emit).with("#{tag}.foo", time, expected)
|
329
329
|
end
|
330
330
|
it { emit }
|
331
331
|
end
|
@@ -335,7 +335,7 @@ describe Fluent::GrepCounterOutput do
|
|
335
335
|
let(:tag) { 'syslog.host1' }
|
336
336
|
before do
|
337
337
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
338
|
-
expect(
|
338
|
+
expect(driver.instance.router).to receive(:emit).with("syslog", time, expected)
|
339
339
|
end
|
340
340
|
it { emit }
|
341
341
|
end
|
@@ -345,7 +345,7 @@ describe Fluent::GrepCounterOutput do
|
|
345
345
|
let(:tag) { 'syslog.host1' }
|
346
346
|
before do
|
347
347
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
348
|
-
expect(
|
348
|
+
expect(driver.instance.router).to receive(:emit).with("syslog", time, expected)
|
349
349
|
end
|
350
350
|
it { emit }
|
351
351
|
end
|
@@ -360,7 +360,7 @@ describe Fluent::GrepCounterOutput do
|
|
360
360
|
let(:tag) { 'syslog.foo.host1' }
|
361
361
|
before do
|
362
362
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
363
|
-
expect(
|
363
|
+
expect(driver.instance.router).to receive(:emit).with("foo.foo.foo", time, expected)
|
364
364
|
end
|
365
365
|
it { emit }
|
366
366
|
end
|
@@ -370,7 +370,7 @@ describe Fluent::GrepCounterOutput do
|
|
370
370
|
let(:tag) { 'syslog.host1' }
|
371
371
|
before do
|
372
372
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
373
|
-
expect(
|
373
|
+
expect(driver.instance.router).to receive(:emit).with("foo.#{tag}", time, expected)
|
374
374
|
end
|
375
375
|
it { emit }
|
376
376
|
end
|
@@ -380,7 +380,7 @@ describe Fluent::GrepCounterOutput do
|
|
380
380
|
let(:tag) { 'syslog.host1' }
|
381
381
|
before do
|
382
382
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
383
|
-
expect(
|
383
|
+
expect(driver.instance.router).to receive(:emit).with("host1", time, expected)
|
384
384
|
end
|
385
385
|
it { emit }
|
386
386
|
end
|
@@ -390,7 +390,7 @@ describe Fluent::GrepCounterOutput do
|
|
390
390
|
let(:tag) { 'syslog.host1' }
|
391
391
|
before do
|
392
392
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
393
|
-
expect(
|
393
|
+
expect(driver.instance.router).to receive(:emit).with("#{tag}.foo", time, expected)
|
394
394
|
end
|
395
395
|
it { emit }
|
396
396
|
end
|
@@ -400,7 +400,7 @@ describe Fluent::GrepCounterOutput do
|
|
400
400
|
let(:tag) { 'syslog.host1' }
|
401
401
|
before do
|
402
402
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
403
|
-
expect(
|
403
|
+
expect(driver.instance.router).to receive(:emit).with("syslog", time, expected)
|
404
404
|
end
|
405
405
|
it { emit }
|
406
406
|
end
|
@@ -411,7 +411,7 @@ describe Fluent::GrepCounterOutput do
|
|
411
411
|
before do
|
412
412
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
413
413
|
message = expected["message"].join('\n')
|
414
|
-
expect(
|
414
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge("message" => message))
|
415
415
|
end
|
416
416
|
it { emit }
|
417
417
|
end
|
@@ -422,7 +422,7 @@ describe Fluent::GrepCounterOutput do
|
|
422
422
|
before do
|
423
423
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
424
424
|
message = expected["message"].join('\n')
|
425
|
-
expect(
|
425
|
+
expect(driver.instance.router).to receive(:emit).with("count.#{tag}", time, expected.merge("message" => message))
|
426
426
|
end
|
427
427
|
it { emit }
|
428
428
|
end
|
@@ -444,7 +444,7 @@ describe Fluent::GrepCounterOutput do
|
|
444
444
|
let(:config) { CONFIG + %[aggregate all \n output_tag count] }
|
445
445
|
before do
|
446
446
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
447
|
-
expect(
|
447
|
+
expect(driver.instance.router).to receive(:emit).with("count", time, expected)
|
448
448
|
end
|
449
449
|
it { emit }
|
450
450
|
end
|
@@ -460,10 +460,10 @@ describe Fluent::GrepCounterOutput do
|
|
460
460
|
let(:config) { CONFIG + %[aggregate tag \n remove_tag_slice 0..-2] }
|
461
461
|
before do
|
462
462
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
463
|
-
expect(
|
463
|
+
expect(driver.instance.router).to receive(:emit).with("foo", time, {
|
464
464
|
"count"=>2, "message"=>["foobar", "foobar"], "input_tag"=>"foo.bar", "input_tag_last"=>"bar"
|
465
465
|
})
|
466
|
-
expect(
|
466
|
+
expect(driver.instance.router).to receive(:emit).with("foo", time, {
|
467
467
|
"count"=>2, "message"=>["foobar", "foobar"], "input_tag"=>"foo.bar2", "input_tag_last"=>"bar2"
|
468
468
|
})
|
469
469
|
end
|
@@ -481,7 +481,7 @@ describe Fluent::GrepCounterOutput do
|
|
481
481
|
let(:config) { CONFIG + %[aggregate out_tag \n remove_tag_slice 0..-2] }
|
482
482
|
before do
|
483
483
|
allow(Fluent::Engine).to receive(:now).and_return(time)
|
484
|
-
expect(
|
484
|
+
expect(driver.instance.router).to receive(:emit).with("foo", time, {
|
485
485
|
"count"=>4, "message"=>["foobar", "foobar", "foobar", "foobar"]
|
486
486
|
})
|
487
487
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|