Skip to content

Commit

Permalink
Include millisecond in timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Ito committed Sep 3, 2015
1 parent baecae1 commit e671e36
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/fluent/plugin/out_elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def connection_options_description
end

def format(tag, time, record)
[tag, time, record].to_msgpack
if time.is_a?(Integer)
[tag, time, record].to_msgpack
else
Fluent::Engine.msgpack_factory.packer.write([tag, time, record]).to_s
end
end

def shutdown
Expand All @@ -132,7 +136,7 @@ def write(chunk)
time = Time.parse record[@time_key]
record['@timestamp'] = record[@time_key]
else
record.merge!({"@timestamp" => Time.at(time).to_datetime.to_s})
record.merge!({"@timestamp" => Time.at(time).strftime("%Y-%m-%dT%H:%M:%S.%L%z")})
end
if @utc_index
target_index = "#{@logstash_prefix}-#{Time.at(time).getutc.strftime("#{@logstash_dateformat}")}"
Expand Down

0 comments on commit e671e36

Please sign in to comment.