Splunk Search

strptime not returning correct results?

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)

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".

Contributor

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