Class: LogStash::Filters::GoogleAppengine

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

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/logstash/filters/google_appengine.rb', line 16

def filter(event)
  begin
    payload = event['protoPayload']
    payload.delete '@type'
    lines = payload.delete 'line'
    if lines
      lines.map.with_index { |line, i|
        line_data = payload.merge line
        line_data['_id'] = @md5.hexdigest line_data['requestId'] + i.to_s
        line_data['message'] = line_data.delete 'logMessage'

        new_event = LogStash::Event::new(line_data)
        filter_matched(new_event)
        yield new_event
      }
    else
      payload['_id'] = @md5.hexdigest payload['requestId']
      payload['time'] = payload['endTime']

      new_event = LogStash::Event::new(payload)
      filter_matched(new_event)
      yield new_event
    end
    event.cancel
  rescue => e
    @logger.error "Failed to process event", :error => e, :data => event
  end
end

#registerObject



12
13
14
# File 'lib/logstash/filters/google_appengine.rb', line 12

def register
  @md5 = Digest::MD5.new
end