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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...