lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.1.3 vs lib/fluent/plugin/out_grepcounter.rb in fluent-plugin-grepcounter-0.1.4

- old
+ new

@@ -5,11 +5,11 @@ config_param :input_key, :string config_param :regexp, :string, :default => nil config_param :count_interval, :time, :default => 5 config_param :exclude, :string, :default => nil config_param :threshold, :integer, :default => 1 - config_param :comparison, :string, :default => '>=' + config_param :comparator, :string, :default => '>=' config_param :output_tag, :string, :default => nil config_param :add_tag_prefix, :string, :default => 'count' config_param :output_with_joined_delimiter, :string, :default => nil config_param :aggregate, :string, :default => 'tag' config_param :replace_invalid_sequence, :bool, :default => false @@ -24,12 +24,12 @@ @input_key = @input_key.to_s @regexp = Regexp.compile(@regexp) if @regexp @exclude = Regexp.compile(@exclude) if @exclude @threshold = @threshold.to_i - unless ['>=', '<='].include?(@comparison) - raise Fluent::ConfigError, "grepcounter: comparison allows >=, <=" + unless ['>=', '<='].include?(@comparator) + raise Fluent::ConfigError, "grepcounter: comparator allows >=, <=" end unless ['tag', 'all'].include?(@aggregate) raise Fluent::ConfigError, "grepcounter: aggregate allows tag/all" end @@ -122,10 +122,11 @@ end end def generate_output(count, matches, tag = nil) return nil if count.nil? - return nil unless eval("#{count} #{@comparison} #{@threshold}") + return nil if count == 0 # ignore 0 because standby nodes receive no message usually + return nil unless eval("#{count} #{@comparator} #{@threshold}") output = {} output['count'] = count output['message'] = @output_with_joined_delimiter.nil? ? matches : matches.join(@output_with_joined_delimiter) if tag output['input_tag'] = tag