lib/logstash/codecs/google_appengine.rb in logstash-codec-google_appengine-1.10.0 vs lib/logstash/codecs/google_appengine.rb in logstash-codec-google_appengine-1.11.0

- old
+ new

@@ -1,18 +1,19 @@ # encoding: utf-8 require "logstash/codecs/base" require "logstash/namespace" require "logstash/codecs/json" -require 'securerandom' +require 'digest' class LogStash::Codecs::GoogleAppengine < LogStash::Codecs::Base config_name "google_appengine" public def register @json = LogStash::Codecs::JSON.new + @md5 = Digest::MD5.new end def decode(data) begin @json.decode data do |json| @@ -39,20 +40,21 @@ def flatten(event) payload = event['protoPayload'] lines = payload['line'] payload.delete '@type' - payload['id'] = payload['requestId'] + if lines payload.delete 'line' lines.map.with_index { |line, i| merged = payload.merge line - merged['id'] = merged['id'] + i.to_s + merged['id'] = @md5.hexdigest merged['requestId'] + i.to_s merged['message'] = merged.delete 'logMessage' merged } else + payload['id'] = @md5.hexdigest payload['requestId'] payload['time'] = payload['endTime'] [payload] end end