Date to string using localtime

Hi, Im trying to convert a date to string with timezone different from UTC

tz = "-03:00"

t = event.get("lastHeartbeat")

and no matter what time is in lastHearbeat allways I get the following



If I just left the variable on event set

event.set("last_heartbeat_text", t )

I get the following:


If I do

            t = event.get("@timestamp").to_s

then I get

"last_heartbeat_text" => 1970-01-01T00:33:41.000Z,

So I think the problem is that [lastHeartbeat] is a string, not a LogStash::Timestamp. Use a date filter to parse and overwrite it.

1 Like

Perheps this?

 date {
   match => [ "lastHeartbeat", "yyyy-MM-dd HH:mm:ss.SSS" ]
   timezone => "America/Detroit"
1 Like

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