class Fluent::NetflowMultiplier
Constants
- FIELDS_TO_MULTIPLY
- HOST_FIELD
- SAMPLING_RATE_FIELD
Attributes
log[RW]
Public Class Methods
new(plugin)
click to toggle source
# File lib/fluent/plugin/netflow_multiplier.rb, line 13 def initialize(plugin) @log = plugin.log @default_sampling_rate = plugin.default_sampling_rate @sampling_rate_per_host = plugin.sampling_rate_per_host @record_suffix = plugin.record_suffix @sampling_rate = {} if @sampling_rate_per_host unless File.exist?(@sampling_rate_per_host) raise ConfigError, "sampling rate definition '#{@sampling_rate_per_host}' not found" end begin @sampling_rate = YAML.load_file(@sampling_rate_per_host) rescue => e raise ConfigError, "Bad syntax in yaml '#{@sampling_rate_per_host}', error_class = #{e.class.name}, error = #{e.message}" end end @estimated_fields = Hash[FIELDS_TO_MULTIPLY.map {|f| [f, f + @record_suffix] }] end
Public Instance Methods
multiply(record)
click to toggle source
# File lib/fluent/plugin/netflow_multiplier.rb, line 35 def multiply(record) rate = sampling_rate(record) @estimated_fields.each do |original, estimated| record[estimated] = record[original].to_i * rate if record[original] end record end
Private Instance Methods
sampling_rate(record)
click to toggle source
# File lib/fluent/plugin/netflow_multiplier.rb, line 51 def sampling_rate(record) return record[SAMPLING_RATE_FIELD].to_i if record[SAMPLING_RATE_FIELD] @sampling_rate[record[HOST_FIELD]] || @default_sampling_rate end