Sha256: 4e7503d015ca9052fb7c20cea6f852e7fb5caf0c085fbb38f0d88260b6182d5d
Contents?: true
Size: 982 Bytes
Versions: 1
Compression:
Stored size: 982 Bytes
Contents
# encoding: utf-8 require "logstash/codecs/base" require "logstash/namespace" require "logstash/codecs/json" class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base config_name "google_appengine" public def register @json = LogStash::Codecs::JSON.new end def decode(data) begin @json.decode(data) do |json| if is_parse_failure(json) return yield json end flatten(json).each { |flattenedJson| yield LogStash::Event.new(flattenedJson) } end rescue => e @logger.error("Failed to process data", :error => e, :data => data) end end end private def is_parse_failure(event) event["tags"] && event["tags"].include?("_jsonparsefailure") end def flatten(event) payload = event['protoPayload'] lines = payload['line'] if lines payload.delete('line') lines.map { |line| payload.merge(line) } else payload['time'] = payload['endTime'] [payload] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logstash-codec-google_appengine-1.4.0 | lib/logstash/codecs/google_appengine.rb |