Splunk Search

Convert time to epoch time & time zone

willadams
Contributor

In my index, I have a field that has been extracted for a "last checkin time". The time shown is GMT and I need to use this field when using a dashboard to accurately show data. I am having a problem with my strptime in that it is not working.

An example is an extracted field ==> 2020-02-13 05:00:29.0
The time is GMT (and it needs to be GMT+8)

I have done the following:

index=someindex source="mysource"
| eval epoch_time=strptime("last_checkin_time", "%Y-%m-%d %H:%M:%S.%3N")

I have tried adjusting the value of eval to use the %Q options but that has not been able to generate anew field that I can use. I have also tried to use %Z at the end of the strptime to try and force timezone but to no avail

I would like to use this time instead of the ingest time (or _time) to drive my dashboard.

Thanks in advance

Tags (1)
0 Karma

to4kawa
Ultra Champion
| eval epoch_time=strptime('last_checkin_time'." +0000", "%F %T.0 %z")

renjith_nair
Legend

@willadams ,

last_checkin_time in strptime shouldn't be in quotes(") which will treat it as a literal. Remove the quotes around it to treat it as variable.

i.e.

eval epoch_time=strptime(last_checkin_time, "%Y-%m-%d %H:%M:%S.%3N")
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...