Skip to content

Commit 873bd80

Browse files
committed
sub-second timestamp support
1 parent face49b commit 873bd80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/fluent/plugin/filter_elasticsearch_timestamp_check.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ def filter(tag, time, record)
1919
existing = record['@timestamp'] || record['timestamp'] || record['time']
2020
if existing
2121
record['@timestamp'] =
22-
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S%z')
22+
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
2323
record['fluent_converted_timestamp'] =
24-
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S%z')
24+
DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
2525
$log.debug("Timestamp parsed: #{record['@timestamp']}")
2626
else
27-
record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
27+
record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
2828
record['fluent_added_timestamp'] =
29-
Time.now.strftime('%Y-%m-%dT%H:%M:%S%z')
29+
Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
3030
$log.debug("Timestamp added: #{record['@timestamp']}")
3131
end
3232
record

0 commit comments

Comments
 (0)