Class: LogStash::Outputs::Cassandra::EventParser

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/cassandra/event_parser.rb

Overview

Responsible for accepting events from the pipeline and returning actions for the SafeSubmitter

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ EventParser

Returns a new instance of EventParser.



8
9
10
11
12
13
14
15
16
# File 'lib/logstash/outputs/cassandra/event_parser.rb', line 8

def initialize(options)
  @logger = options['logger']
  @table = options['table']
  @filter_transform_event_key = options['filter_transform_event_key']
  assert_filter_transform_structure(options['filter_transform']) if options['filter_transform']
  @filter_transform = options['filter_transform']
  @hints = options['hints']
  @ignore_bad_values = options['ignore_bad_values']
end

Instance Method Details

#parse(event) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/logstash/outputs/cassandra/event_parser.rb', line 18

def parse(event)
  action = {}
  begin
    action['table'] = event.sprintf(@table)
    filter_transform = get_filter_transform(event)
    if filter_transform
      action['data'] = {}
      filter_transform.each { |filter|
        add_event_value_from_filter_to_action(event, filter, action)
      }
    else
      add_event_data_using_configured_hints(event, action)
    end
    @logger.debug('event parsed to action', :action => action)
  rescue Exception => e
    @logger.error('failed parsing event', :event => event, :error => e)
    action = nil
  end
  action
end