Class: LogStash::Filters::Sequence
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Sequence
- Defined in:
- lib/logstash/filters/sequence.rb
Overview
This filter will adds a sequence number to a log entry. A the start of logstash the id start with a timestamp and increment by 1 for each log event.
Instance Method Summary collapse
- #filter(event) ⇒ Object
-
#initialize(config = {}) ⇒ Sequence
constructor
A new instance of Sequence.
- #register ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Sequence
Returns a new instance of Sequence.
31 32 33 34 35 36 37 38 |
# File 'lib/logstash/filters/sequence.rb', line 31 def initialize(config = {}) super @threadsafe = false # This filter needs to keep state. @sequence=DateTime.now.strftime('%Q').to_i end |
Instance Method Details
#filter(event) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/logstash/filters/sequence.rb', line 41 def filter(event) return unless filter?(event) event[@field] = @sequence @sequence = @sequence + 1 filter_matched(event) end |
#register ⇒ Object
26 27 28 |
# File 'lib/logstash/filters/sequence.rb', line 26 def register # Nothing end |