Filter a string date format on logstash


(Djelouah Laâla) #1

Hi guys,

I get data from an sql server database and i have a date on a string format like this :
"2017-04-25 00:00:00 +0200" and I want to use grok filter to transform this to a similar format to @timestamp
I have this code grok { match => ["message","(?<log_date>%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND},[0-9]{3}) %{GREEDYDATA:jsonfield}"] }

In Kibana i got this error message :
Expected numeric type on field [txechecczhier_date], but got [string]

So i suppose that the problem come from my filter, any idea guys to help to solve this?

Thank you


(Magnus Bäck) #2

Extract the whole timestamp string to a separate field and use the date filter to parse it into @timestamp.


(Djelouah Laâla) #3

Thank you for replying me as quickly. When i delete the filter i have this result in a file :
{"txechecczhier_date":"2017-04-25 00:00:00 +0200","txechecczhier_tx":2.08,"@version":"1","@timestamp":"2017-04-28T12:51:01.476Z"}
I want to display my txechecczhier_date in kibana, the date is different from the timestamp. With date filter we can transform a string to a timestamp?


(Magnus Bäck) #4

With date filter we can transform a string to a timestamp?

Yes, that's exactly what that filter does.


(Djelouah Laâla) #5

Okay ! thank you, i will look in this way


(system) #6

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