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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cceea9a84d43542c30eda8ae0b2d3127d3a8ee8a
4
- data.tar.gz: ed10007f880499d164493b9c42a5edaefb0525c4
3
+ metadata.gz: 96a67e39368ff883543e1999186e185e8ad6159f
4
+ data.tar.gz: 8e4ff3eb1e5d9660ddd08a04bedbbcebf5098f14
5
5
  SHA512:
6
- metadata.gz: 66b848914ad05a5f45ddc55cdd3e3e0c01dbd5046879cd1bef6a910f194e23cf6b3ce631a9b008b03d0ce5fc27747e64b049ed10d08ce7768334250c637014b3
7
- data.tar.gz: f5f6c761d747e58dc7ed9f14e94383221e7476376bf1764e22ac777e14c42aa86d54f538fe77a35ce1e2ad01748ce70164543e44a1faf0e42677b7c441c55b80
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
- - comparison
79
+ - comparator
80
80
 
81
- The comparison operator for the threshold (either of `>=` or `<=`). Default is `>=`, i.e., emit if count >= threshold.
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.3"
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 :comparison, :string, :default => '>='
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?(@comparison)
30
- raise Fluent::ConfigError, "grepcounter: comparison allows >=, <="
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 unless eval("#{count} #{@comparison} #{@threshold}")
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 comparison' do
44
+ context 'invalid comparator' do
45
45
  let(:config) do
46
46
  CONFIG + %[
47
- comparison foo
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(:comparison) { should == '>=' }
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 "comparison <=" do
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
- comparison <=
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
- comparison <=
287
+ comparator <=
288
288
  ]
289
289
  end
290
290
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-grepcounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi SEO