class LogStash::Filters::Metricize

The metricize filter takes complex events containing a number of metrics and splits these up into multiple events, each holding a single metric.

Example:

Assume the following filter configuration:

filter {
  %PLUGIN% {
    metrics => [ "metric1", "metric2" ]
  }
}

Assuming the following event is passed in:

{
     type => "type A"
     metric1 => "value1"
     metric2 => "value2"
}

This will result in the following 2 events being generated in addition to the original event:

{                               {
    type => "type A"                type => "type A"
    metric => "metric1"             metric => "metric2"
    value => "value1"               value => "value2"
}                               }

Public Instance Methods

filter(event) { |clone| ... } click to toggle source
# File lib/logstash/filters/metricize.rb, line 58
def filter(event)
  
  base_event = event.clone
  @metrics.each do |field|
    base_event.remove(field)
  end  

  @metrics.each do |metric|
    if event[metric]
      clone = base_event.clone
      clone[@metric_field_name] = metric
      clone[@value_field_name] = event[metric]
      @logger.debug("Created metricized event ", :clone => clone, :event => event)
      yield clone
    end
  end

  if @drop_original_event
    event.cancel()
  end

  base_event.cancel()
end
register() click to toggle source
# File lib/logstash/filters/metricize.rb, line 53
def register
  # Nothing to do
end