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!

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...