This widget could not be displayed.
This widget could not be displayed.
Splunk Search

Time conversion

Nith1
Path Finder

Hi Team

 

I have the time in this format "startTime":1606406489009 i wanted to convert it to date-month-year hour-seconds can someone please help me with the query

Labels (1)
Tags (1)
This widget could not be displayed.
0 Karma
This widget could not be displayed.
Reply
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Not sure whether there is another question here - the rex extracts the digits as a number, the number represents milliseconds since epoch, time is usually stored as seconds since epoch so divide this number by 1000, this can be done with all your events with this format for time, to display in human-readable format use fieldformat with the appropriate settings.

View solution in original post

This widget could not be displayed.
0 Karma
This widget could not be displayed.
This widget could not be displayed.
Reply

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="\"startTime\":1606406489009"
| rex "startTime\":(?<time>\d+)"
| eval seconds=time/1000
| fieldformat seconds=strftime(seconds,"%Y-%m-%d %H:%M:%S.%Q")
This widget could not be displayed.
0 Karma
This widget could not be displayed.
This widget could not be displayed.
Reply

Nith1
Path Finder

Hi @ITWhisperer 

Thanks for the reply its working, but if we have all the logs with same kind for starttime how can we resolve that

 

Thanks

Tags (1)
This widget could not be displayed.
0 Karma
This widget could not be displayed.
This widget could not be displayed.
Reply

ITWhisperer
SplunkTrust
SplunkTrust

Not sure whether there is another question here - the rex extracts the digits as a number, the number represents milliseconds since epoch, time is usually stored as seconds since epoch so divide this number by 1000, this can be done with all your events with this format for time, to display in human-readable format use fieldformat with the appropriate settings.

This widget could not be displayed.
0 Karma
This widget could not be displayed.
This widget could not be displayed.
Reply

isoutamo
SplunkTrust
SplunkTrust
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Reply
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
Get Updates on the Splunk Community!