Class: Fluent::NetflowMultiplier
- Inherits:
-
Object
- Object
- Fluent::NetflowMultiplier
- Defined in:
- lib/fluent/plugin/netflow_multiplier.rb
Constant Summary collapse
- FIELDS_TO_MULTIPLY =
%w[ in_pkts in_bytes flows mul_dst_pkts mul_dst_bytes out_bytes out_pkts total_bytes_exp total_pkts_exp total_flows_exp ]
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
-
#initialize(plugin) ⇒ NetflowMultiplier
constructor
A new instance of NetflowMultiplier.
- #multiply(record) ⇒ Object
Constructor Details
#initialize(plugin) ⇒ NetflowMultiplier
Returns a new instance of NetflowMultiplier.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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.}" end end @estimated_fields = Hash[FIELDS_TO_MULTIPLY.map {|f| [f, f + @record_suffix] }] end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
6 7 8 |
# File 'lib/fluent/plugin/netflow_multiplier.rb', line 6 def log @log end |
Instance Method Details
#multiply(record) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# 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 |