Dear experts,
I am dealing with parsing issues with date format. The date format looks like ISO 8601 : grok filter is perfectly running but no way to keep the log date time stamp as @timestamp in the date section. This only workaround I found is to add the line remove => [ "logTimestamp" ] in the date section.
But this way, I miss what I would like to achieve : use the log time stamp as the elastisearch @timestamp.
Thanks for your support
Here are elasticsearch logs:
[2017-10-09T18:15:14,638][DEBUG][o.e.a.b.TransportShardBulkAction] [i-0012c16b-elk-server-MyInstanceES] [logstash-2017.10.09][4] failed to execute bulk item (index) BulkShardRequest [[logstash-2017.10.09][4]] containing [index {[logstash-2017.10.09][logs][AV8B6zzOeluEE4o-QuEo], source[{"path":"/mondata/log/mongod.log","logTimestamp":"2017-10-09T18:15:14.036+0200","component":"NETWORK","@timestamp":"2017-10-09T16:15:14.036Z","logLevel":"I","@version":"1","host":"0.0.0.0","context":"initandlisten","message":"2017-10-09T18:15:14.036+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:50490 #1203802 (2 connections now open)","mongoDB_message":"connection accepted from 127.0.0.1:50490 #1203802 (2 connections now open)"}]}]
org.elasticsearch.index.mapper.MapperParsingException: failed to parse [logTimestamp]
Caused by: java.lang.IllegalArgumentException: Invalid format: "2017-10-09T18:15:14.036+0200" is malformed at "-10-09T18:15:14.036+0200"
Here are some MongoDB log entries:
2017-10-09T18:10:28.012+0200 I NETWORK [conn1203655] end connection 127.0.0.1:50181 (1 connection now open)
2017-10-09T18:10:30.092+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:50183 #1203656 (2 connections now open)
2017-10-09T18:10:30.101+0200 I NETWORK [conn1203656] end connection 127.0.0.1:50183 (1 connection now open)
Here is the grok filter for logstash:
filter {
grok {
match => { "message" =>
"%{TIMESTAMP_ISO8601:logTimestamp} %{WORD:logLevel} %{WORD:component} [%{WORD:context}] %{GREEDYDATA:mongoDB_message}"
}
}
if "_grokparsefailure" in [tags] {
drop{ }
}
date {
match => [ "logTimestamp", "ISO8601", "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZZ" ]
target => "@timestamp"
}
}