logstash-plugins / logstash-output-elastic_app_search

Apache License 2.0
0 stars 9 forks source link

explicity convert logstash timestamp to string #7

Open jsvd opened 5 years ago

jsvd commented 5 years ago

currently we rely on the java client's json encoding to encode all objects. However, for LogStash::Timestamp objects the result is a strange object:

irb(main):005:0> com.google.gson.Gson.new.toJson(LogStash::Timestamp.now)
=> "{\"timestamp\":{\"time\":{\"iMillis\":1562672762386,\"iChronology\":{\"iBase\":{\"iMinDaysInFirstWeek\":4}}}},\"flags\":0}"

While using LogStash::Json encoding we get the ISO8601 string:

irb(main):006:0> LogStash::Json.dump(LogStash::Timestamp.now)
=> "\"2019-07-09T11:46:22.645Z\""

To avoid further mixups, when timestamp_destination is used we should convert the timestamp to this iso8601 format.