Class: LogStash::Filters::Metricize
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Metricize
- Defined in:
- lib/logstash/filters/metricize.rb
Overview
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"
} }
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/logstash/filters/metricize.rb', line 57 def filter(event) base_event = event.clone @metrics.each do |field| base_event.remove(field) end @metrics.each do |metric_key| metric_value = event.get(metric_key) if metric_value clone = base_event.clone clone.set(@metric_field_name, metric_key) clone.set(@value_field_name, metric_value) @logger.debug? && @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 ⇒ Object
52 53 54 |
# File 'lib/logstash/filters/metricize.rb', line 52 def register # Nothing to do end |