Splunk Search

Why am I Not seeing any results with strftime?

mninansplunk
Path Finder

Hello everyone,

I am going crazy trying to figure out why this isn't working.  I have a field called "alert.createdAt" that contains an EPOCH time.  (1693398386408).  I need to convert this to be Human Readable (08/30/2023 09:26:47).  However, when using the strftime, I don't see anything being returned.

My Search is:

SEARCH | eval c_time=strftime (alert.createdAt,"%m-%d-%Y %H:%M:%S") | table c_time

I have been going thru all of the previous solutions I could find, but I can't seem to get this to work.  Is there another way to achieve this, or am I just way off on how I am trying to do this. : )

Thanks for any help, much appreciated

Tom

 

 

 

 

Labels (2)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Field names with special characters such as dots (.) need to be referenced in single quotes, plus it looks like you time value is in milliseconds not seconds (used by epoch time). Try this:

| makeresults
| fields - _time
| eval alert.createdAt=1693398386408
| eval c_time=strftime ('alert.createdAt'/1000,"%m-%d-%Y %H:%M:%S.%3N")
| table c_time

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Field names with special characters such as dots (.) need to be referenced in single quotes, plus it looks like you time value is in milliseconds not seconds (used by epoch time). Try this:

| makeresults
| fields - _time
| eval alert.createdAt=1693398386408
| eval c_time=strftime ('alert.createdAt'/1000,"%m-%d-%Y %H:%M:%S.%3N")
| table c_time

mninansplunk
Path Finder

Thank you very much for the quick help, that did the trick.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...