Sha256: 5f902a4e3d81de8e6c9f0f074022d08615d34501651c855f4d1d9d9ddf83d24a

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require "logstash/environment"
require 'digest'

class LogStash::Filters::GoogleAppengine < LogStash::Filters::Base

  config_name "google_appengine"

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

  def filter(event)
    return unless filter?(event)

    payload = event['protoPayload']
    payload.delete '@type'
    lines = payload.delete 'line'
    if lines
      @logger.error("Encountered line event")
      lines.each_with_index do |line, i|
        next if line.empty?

        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)
        @logger.error("Emitting LINE event", 'line_event'=> new_event)
        yield new_event
      end
    # else
    #   payload['_id'] = @md5.hexdigest payload['requestId']
    #   payload['time'] = payload['endTime']
    #
    #   new_event = LogStash::Event::new(payload)
    #   filter_matched(new_event)
    #
    #   @logger.error("Emitting REGULAR event", 'line_event'=> new_event)
    #   yield new_event
    end

    event.cancel
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-filter-google_appengine-0.90.0 lib/logstash/filters/google_appengine.rb