How to format date in logstash

(Saidesh Kilaru) #1

I have date string and i need to convert that to date with specific format.
for example: dattime="2017-12-12 11:12:00";
date {
match => [ "dattime", "yyyy-MM-dd HH:mm:ss" ]
target => "dattime"

when iam doing this iam getting date in iso 8601 format.

how can i get a date in specific format from a string/ how to format iso 8601 date to other date pattern (custom)

as i am new to logtash facing issues to solve this. please help me.
Thanks in advance

(Magnus B├Ąck) #2

Formatting a timestamp in a specific format is something that should be done by the presentation layer so I think you're focusing on the wrong thing.

That said, the value produced by the date filter will be of a timestamp type that I think has methods for formatting (probably named strftime). If so you can use a ruby filter to call that method and format the timestamp in any way supported by the date library.

(system) #3

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