Hi, Im trying to convert a date to string with timezone different from UTC
tz = "-03:00"
t = event.get("lastHeartbeat")
event.set("last_heartbeat_text", Time.at(t.to_f).localtime(tz))
and no matter what time is in lastHearbeat allways I get the following
1970-01-01T00:33:41.000Z
If I just left the variable on event set
event.set("last_heartbeat_text", t )
I get the following:
Badger
November 3, 2021, 7:53pm
2
If I do
t = event.get("@timestamp").to_s
event.set("last_heartbeat_text", Time.at(t.to_f).localtime(tz))
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
Rios
(Rios)
November 3, 2021, 9:16pm
3
Perheps this?
date {
match => [ "lastHeartbeat", "yyyy-MM-dd HH:mm:ss.SSS" ]
timezone => "America/Detroit"
}
1 Like
system
(system)
Closed
December 1, 2021, 9:17pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.