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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...