fluent-plugin-grepcounter 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/fluent-plugin-grepcounter.gemspec +1 -1
- data/lib/fluent/plugin/out_grepcounter.rb +5 -4
- data/spec/out_grepcounter_spec.rb +6 -6
- 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: 96a67e39368ff883543e1999186e185e8ad6159f
|
4
|
+
data.tar.gz: 8e4ff3eb1e5d9660ddd08a04bedbbcebf5098f14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fb377c61e7318b2efa53d1cc76de6831d982736df5755d17b49bbcc9b869e24cdff3d28afbdbdfa21db99c960bcb3cd65083fde8a9c934030157d3b39c7558b
|
7
|
+
data.tar.gz: 323bdaf536cba05342c8b395599bf1235937a3cbbcb383da0a6a801d79d6a6f803e5f223b122012e9f9595049ae9d4d6a3645a3480d90e3f455fc49e4e7c3698
|
data/README.md
CHANGED
@@ -76,9 +76,10 @@ Then, output bocomes as belows (indented). You can see the `message` field is jo
|
|
76
76
|
|
77
77
|
The threshold number to emit
|
78
78
|
|
79
|
-
-
|
79
|
+
- comparator
|
80
80
|
|
81
|
-
The
|
81
|
+
The comparation operator for the threshold (either of `>=` or `<=`). Default is `>=`, i.e., emit if count >= threshold.
|
82
|
+
NOTE: 0 count message will not be emitted even if `<=` is specified because standby nodes receive no message usually.
|
82
83
|
|
83
84
|
- output\_with\_joined\_delimiter
|
84
85
|
|
@@ -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.1.
|
6
|
+
s.version = "0.1.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"
|
@@ -7,7 +7,7 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
7
7
|
config_param :count_interval, :time, :default => 5
|
8
8
|
config_param :exclude, :string, :default => nil
|
9
9
|
config_param :threshold, :integer, :default => 1
|
10
|
-
config_param :
|
10
|
+
config_param :comparator, :string, :default => '>='
|
11
11
|
config_param :output_tag, :string, :default => nil
|
12
12
|
config_param :add_tag_prefix, :string, :default => 'count'
|
13
13
|
config_param :output_with_joined_delimiter, :string, :default => nil
|
@@ -26,8 +26,8 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
26
26
|
@exclude = Regexp.compile(@exclude) if @exclude
|
27
27
|
@threshold = @threshold.to_i
|
28
28
|
|
29
|
-
unless ['>=', '<='].include?(@
|
30
|
-
raise Fluent::ConfigError, "grepcounter:
|
29
|
+
unless ['>=', '<='].include?(@comparator)
|
30
|
+
raise Fluent::ConfigError, "grepcounter: comparator allows >=, <="
|
31
31
|
end
|
32
32
|
|
33
33
|
unless ['tag', 'all'].include?(@aggregate)
|
@@ -124,7 +124,8 @@ class Fluent::GrepCounterOutput < Fluent::Output
|
|
124
124
|
|
125
125
|
def generate_output(count, matches, tag = nil)
|
126
126
|
return nil if count.nil?
|
127
|
-
return nil
|
127
|
+
return nil if count == 0 # ignore 0 because standby nodes receive no message usually
|
128
|
+
return nil unless eval("#{count} #{@comparator} #{@threshold}")
|
128
129
|
output = {}
|
129
130
|
output['count'] = count
|
130
131
|
output['message'] = @output_with_joined_delimiter.nil? ? matches : matches.join(@output_with_joined_delimiter)
|
@@ -41,10 +41,10 @@ describe Fluent::GrepCounterOutput do
|
|
41
41
|
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
42
42
|
end
|
43
43
|
|
44
|
-
context 'invalid
|
44
|
+
context 'invalid comparator' do
|
45
45
|
let(:config) do
|
46
46
|
CONFIG + %[
|
47
|
-
|
47
|
+
comparator foo
|
48
48
|
]
|
49
49
|
end
|
50
50
|
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
@@ -61,7 +61,7 @@ describe Fluent::GrepCounterOutput do
|
|
61
61
|
its(:regexp) { should be_nil }
|
62
62
|
its(:exclude) { should be_nil }
|
63
63
|
its(:threshold) { should == 1 }
|
64
|
-
its(:
|
64
|
+
its(:comparator) { should == '>=' }
|
65
65
|
its(:output_tag) { should be_nil }
|
66
66
|
its(:add_tag_prefix) { should == 'count' }
|
67
67
|
end
|
@@ -259,13 +259,13 @@ describe Fluent::GrepCounterOutput do
|
|
259
259
|
it { expect { emit }.not_to raise_error(ArgumentError) }
|
260
260
|
end
|
261
261
|
|
262
|
-
describe "
|
262
|
+
describe "comparator <=" do
|
263
263
|
context 'threshold (hit)' do
|
264
264
|
let(:config) do
|
265
265
|
CONFIG + %[
|
266
266
|
regexp WARN
|
267
267
|
threshold 3
|
268
|
-
|
268
|
+
comparator <=
|
269
269
|
]
|
270
270
|
end
|
271
271
|
before do
|
@@ -284,7 +284,7 @@ describe Fluent::GrepCounterOutput do
|
|
284
284
|
CONFIG + %[
|
285
285
|
regexp WARN
|
286
286
|
threshold 2
|
287
|
-
|
287
|
+
comparator <=
|
288
288
|
]
|
289
289
|
end
|
290
290
|
before do
|