Splunk Search

How to convert epoch time to a readable format?

New Member

I'm currently creating a dashboard and need to put the time of an event into a readable format as I currently see a number such as: 1571187604872

The search I am running is:

index=BLAH Field1="BLAHBLAH" 
|eval Time=strftime(Field2, "%Y/%m/%d %H:%M")
|table Time Field3 Field4 Field5 Field6

This search doesn't gives me a readable time but the time isn't correct as the date are all the same with the year being 9999. Can somebody give me some guidance on how to correct this please?

0 Karma

Esteemed Legend

Sometimes the field is milliseconds, not seconds; try this:

index=BLAH Field1="BLAHBLAH"
| eval Time=strftime(tonumber(Field2) / 1000, "%Y/%m/%d %H:%M")
| table Time Field3 Field4 Field5 Field6
0 Karma

Ultra Champion

looks like you epoch has milliseconds in it ... but doesnt have the dot . in place
1571187604872 should be 1571187604.872
try this website:
then try in splunk:

 | makeresults count=1
    | eval data = "1571187604872 1571187614872 1571187605872 1571187601000"
    | makemv data
    | mvexpand data
    | eval bad_time = strftime(data, "%Y/%m/%d %H:%M")
    | eval fix_mili = tonumber(data / 1000)
    | eval good_time = strftime(fix_mili, "%Y/%m/%d %H:%M:%S")

hope it helps

Get Updates on the Splunk Community!

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...

Understanding Generative AI Techniques and Their Application in Cybersecurity

Watch On-Demand Artificial intelligence is the talk of the town nowadays, with industries of all kinds ...