Hello,
I'm new in topic ELK stuff and I try to solve my problem with date parsing. I have two fields with date and time stamp which I connected together. Then I want mark that pool as Date and send to Elastic:
My Log looks like:
|2021/05/01|07:54:15|some Other fields........
And so far so good.
I'm able to parse all interesting fields with following configuration:
input {
file {
...
}
}
filter {
grok {
match => { "message" =>"(?<Date_stamp>%{YEAR}/%{MONTHNUM}/%{MONTHDAY})\|%{TIME:Time_Stamp}\|%{GREEDYDATA}....
}
#so Date_stamp is: yyyy/MM/dd, Time_Stamp is: HH:mm:ss
mutate {
add_field => {
"Event" => "%{Date_stamp}%{Time_Stamp}"
#Put all together and should be: yyyy/MM/ddHH:mm:ss
}
}
date {
match => [ "Event", "yyyy/MM/ddHH:mm:ss", "yyyy-MM-dd HH:mm:ss" ]
target => "Event"
}
}
output {
elasticsearch {
index => "logstash-%{+yyyy.MM.dd}"
hosts => [ "localhost:9200" ]
user => ******
password => *******
}
stdout { codec => rubydebug }
}
I checked on the logstash console output and it looks like:
{
"Event" => 2021-05-01T07:54:15.000Z,
"Other field1" => "xxxxxxx",
"Other field2" => "xxxxxxx",
}
Question: why he puts 'T' on the middle and '.SSSZ' in the end? How I can fix it?
There is also in console one warning from Elasticsearch side:
"error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [Event] of type [date] in document .....
Preview of field's value: '2021-05-11T07:54:15.000Z'", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"failed to parse date field [2021-05-11T05:35:08.000Z] with format [yyyy/MM/ddHH:mm:ss||yyyy-MM-ddHH:mm:ss.SSSZ]", "caused_by"=>{"type"=>"date_time_parse_exception", "reason"=>"Failed to parse with all enclosed parsers"
How can I get rid with that error?
Regards and many thanks for help
Karl Wolf