Why is my Logstash date plugin return PM as AM?

Hi,

I am using ELK GA 5.0.0. I am trying to parse my date 2018-03-18 01:44:25 PM. I am expecting 01 PM as 13 in 24 hr format in @timestamp field. Below is the config.

input {
	generator {
		message => "2018-03-18 01:44:25 PM"
		count => 1
	}
}

filter {
	grok{
		match => { "message" => "%{GREEDYDATA:mydate}" }
	}
	date {
		match => [ "mydate", "yyyy-MM-dd HH:mm:SS aa" ]
		timezone => "GMT"
		target => "@timestamp"
	}
} 

output{
	stdout{ codec => json }
}

it returns;

{"sequence":0,"mydate":"2018-03-18 01:44:25 PM","@timestamp":"2018-03-18T01:44:00.250Z","@version":"1","host":"iflyresdev1","message":"2018-03-18 01:44:25 PM"}

see @timestamp":"2018-03-18T01:44:00.250Z here, which means the date is parsed as 01 AM. How can I fix this?

Thanks in advance.

I tried yyyy-MM-dd hh:mm:ss aa and it works.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.