Dashboards & Visualizations

Date showing in a str format

Eva53
Explorer

Hello !

I have a date showing in this format (str) : 20240324090045.560961-240

I've been trying to convert it into a readable date format for my dashboards, with no success so far.

Does someone have a solution ? I'm getting nowhere with the splunk docs or other solved problems.

Thanks !

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Depending on what you are trying to do with the StartTime, you may need one or both of the evals

eventtype=windows_index_windows eventtype=hostmon_windows host="///" (Name="///*") OR (Name="///*") OR (Name="///*")  StartTime="*"
| table Name, StartTime
``` Parse strptime the StartTime into an epoch time value ```
| eval epochStartTime=strptime(StartTime,"%Y%m%d%H%M%S.%6N%z")
``` Format strftime the epoch time into a string ```
| eval stringStartTime=strftime(epochStartTime,"%F %T.%6N")

View solution in original post

Eva53
Explorer

It works perfectly for the specified date, but how do I do include it in my command if I want your answer to be the format for every StartTime :

eventtype=windows_index_windows eventtype=hostmon_windows host="///" (Name="///*") OR (Name="///*") OR (Name="///*")  StartTime="*"
| table Name, StartTime

Sorry if I'm not clear, English is not my first language 


0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Depending on what you are trying to do with the StartTime, you may need one or both of the evals

eventtype=windows_index_windows eventtype=hostmon_windows host="///" (Name="///*") OR (Name="///*") OR (Name="///*")  StartTime="*"
| table Name, StartTime
``` Parse strptime the StartTime into an epoch time value ```
| eval epochStartTime=strptime(StartTime,"%Y%m%d%H%M%S.%6N%z")
``` Format strftime the epoch time into a string ```
| eval stringStartTime=strftime(epochStartTime,"%F %T.%6N")

Eva53
Explorer

It worked !

Thank you so much I've been struggling with that problem for so long !

Have a wonderful day

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Does this help?

| makeresults
| eval time="20240324090045.560961-240"
| eval _time=strptime(time,"%Y%m%d%H%M%S.%6N%z")
| eval stringtime=strftime(_time,"%F %T.%6N")
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...