Splunk Search

strptime not returning correct results?

RVDowning
Contributor

I have a field in a log: TotalReportRunTime=0:3.313 which is in the format minutes:seconds.milliseconds.

If I use eval runtime=strptime(TotalReportRunTime, "%M:%S.%3N") nothing gets returned.

If I use eval runtime=strptime(TotalReportRunTime, "%H:%M.%3N") I get a value 1336104120.000000 which does not represent 3.313 seconds.

Is there another approach that would work? (Release is 4.3)

Tags (3)

sowings
Splunk Employee
Splunk Employee

Based upon feedback I've seen from others, it seems that both strptime and convert mktime() create values relative to the current epoch time. That is, when you're attempting to parse a duration like 1m32s (or so), strptime and mktime interpret that as "1 min 32 sec from now". The value you quoted is an epoch time, representing "Thu May 3 21:02:00 2012 EDT".

RVDowning
Contributor

I got around the issue by using convert mstime(TotalReportRunTime).

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...