Class: LogStash::Filters::Age

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/age.rb

Overview

A simple filter for calculating the age of an event.

This filter calculates the age of an event by subtracting the event timestamp from the current timestamp. This allows you to drop Logstash events that are older than some threshold.

source,ruby

filter

age {

if [@metadata][age] > 86400 {
  drop {}
}

}

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



34
35
36
37
# File 'lib/logstash/filters/age.rb', line 34

def filter(event)
  event.set(@target, Time.now.to_f - event.timestamp.to_f)
  filter_matched(event)
end

#registerObject



29
30
31
# File 'lib/logstash/filters/age.rb', line 29

def register
  # Nothing to do here
end