require 'fluent/plugin/output' class Fluent::Plugin::NumericMonitorOutput < Fluent::Plugin::Output Fluent::Plugin.register_output('numeric_monitor', self) helpers :event_emitter, :timer EMIT_STREAM_RECORDS = 100 config_param :count_interval, :time, default: 60, desc: 'The interval time to monitor in seconds.' config_param :unit, :enum, list: [:minute, :hour, :day], default: nil config_param :tag, :string, default: 'monitor', desc: 'The output tag.' config_param :aggregate, :enum, list: [:tag, :all], default: :tag, desc: "Calculate input events per tags, or all events" config_param :output_per_tag, :bool, default: false, desc: 'Produce monitor result per input tags.' config_param :input_tag_remove_prefix, :string, default: nil, desc: 'The prefix string which will be removed from the input tag.' config_param :monitor_key, :string, desc: 'The key to monitor in the event record.' config_param :output_key_prefix, :string, default: nil, desc: 'The prefix string which will be added to the output key.' config_param :percentiles, :array, value_type: :integer, default: nil, desc: 'Activate the percentile monitoring. ' \ 'Must be specified between 1 and 99 by integer separeted by , (comma).' config_param :samples_limit, :integer, default: 1000000, desc: 'The limit number of sampling.' config_param :tag_prefix, :string, default: nil, desc: 'The prefix string to be added to input tags. Use with "output_per_tag yes".', deprecated: 'Use @label routing instead.' attr_accessor :count, :last_checked def configure(conf) label_routing_specified = conf.has_key?('@label') super if @unit @count_interval = case @unit when :minute then 60 when :hour then 3600 when :day then 86400 else raise "unknown unit: #{@unit}" end end if @input_tag_remove_prefix @removed_prefix_string = @input_tag_remove_prefix + '.' @removed_length = @removed_prefix_string.length end @key_prefix_string = '' if @output_key_prefix @key_prefix_string = @output_key_prefix + '_' end if @output_per_tag && (!label_routing_specified && !@tag_prefix) raise Fluent::ConfigError, "specify @label to route output events into other