From 2fbdf3c1f5af22b2b32f06b45ca1feba885651bc Mon Sep 17 00:00:00 2001 From: Holger Just Date: Mon, 14 Aug 2017 13:27:18 +0200 Subject: [PATCH] Don't create the @version fields in events by default This field is only relevant when actually sending JSON to Logstash. Other formats don't need it. It is thus more desireable to only include this field in a specific logstash JSON encoder. --- lib/rackstash/buffer.rb | 8 ++------ spec/rackstash/buffer_spec.rb | 3 +-- spec/rackstash/sink_spec.rb | 3 +-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/rackstash/buffer.rb b/lib/rackstash/buffer.rb index 080b4c3..888a1f0 100644 --- a/lib/rackstash/buffer.rb +++ b/lib/rackstash/buffer.rb @@ -51,7 +51,7 @@ module Rackstash FIELD_MESSAGE, # filled with #{add_message} FIELD_TAGS, # set with {#tag} FIELD_TIMESTAMP, # an ISO8601 timestamp of the log event - FIELD_VERSION, # the version of the schema. Currently "1" + FIELD_VERSION, # the version of the Logstash JSON schema. Usually "1" ].freeze # @!attribute [r] fields @@ -269,8 +269,6 @@ module Rackstash # now contains an array of {Message} objects. # * We add the buffer's timestamp to the `event['@timestamp]` field as an # ISO 8601 formatted string. The timestamp is always in UTC. - # * We add the version of the logstash event format as - # `event[@version] = 1`. # # The typical event emitted here looks like this: # @@ -282,8 +280,7 @@ module Rackstash # #, # # # ], - # "@timestamp" => "2016-10-17T13:37:42.000Z", - # "@version" => "1" + # "@timestamp" => "2016-10-17T13:37:42.000Z" # } # # @@ -312,7 +309,6 @@ module Rackstash event[FIELD_MESSAGE] = messages event[FIELD_TIMESTAMP] = timestamp - event[FIELD_VERSION] = '1'.freeze event end diff --git a/spec/rackstash/buffer_spec.rb b/spec/rackstash/buffer_spec.rb index abb24ce..3994c0a 100644 --- a/spec/rackstash/buffer_spec.rb +++ b/spec/rackstash/buffer_spec.rb @@ -429,8 +429,7 @@ describe Rackstash::Buffer do 'foo' => 'bar', 'message' => [message], 'tags' => ['some_tag'], - '@timestamp' => instance_of(String), - '@version' => '1' + '@timestamp' => instance_of(String) ) end end diff --git a/spec/rackstash/sink_spec.rb b/spec/rackstash/sink_spec.rb index 7395105..a04c801 100644 --- a/spec/rackstash/sink_spec.rb +++ b/spec/rackstash/sink_spec.rb @@ -146,8 +146,7 @@ describe Rackstash::Sink do event_spec = { 'message' => [], 'tags' => [], - '@timestamp' => instance_of(String), - '@version' => '1' + '@timestamp' => instance_of(String) } # only the first event is duplicated