Splunk Search

How to convert milliseconds to minutes or seconds

monipinni
Explorer
base search | spath "body.totalTime" | search "body.totalTime"=426287

How to convert milliseconds to minutes or seconds?

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

base search 
| spath "body.totalTime" 
| search "body.totalTime"=426287
| fieldformat "body.totalTime" = round(('body.totalTime' / 1000), 3)

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

base search 
| spath "body.totalTime" 
| search "body.totalTime"=426287
| fieldformat "body.totalTime" = round(('body.totalTime' / 1000), 3)
0 Karma

vnravikumar
Champion

Hi

Try this

....| eval inSeconds = round('body.totalTime' / 1000,2) 
| eval output = tostring(inSeconds, "duration")
0 Karma

woodcock
Esteemed Legend

Like this:

base search 
| spath "body.totalTime" 
| search "body.totalTime"=426287
| fieldformat "body.totalTime" = tostring('body.totalTime' / 1000, "duration")
0 Karma

monipinni
Explorer

@woodcock ck :Tried this one

base search | search "body.totalTime"=82534 | fieldformat "body.totalTime" = tostring('body.totalTime' / 1000, "duration") | table body.totalTime

Result I am getting like this 00:01:22.534000000000006 instead of 82.534 sec

woodcock
Esteemed Legend

I was giving you what I thought was a "better" answer. See my new answer for the "exact" answer to what you asked.

0 Karma

Anantha123
Communicator

try this

base search|spath "body.totalTime" | eval body.seconds=body.totalTime*1000 | eval body.minutes=body.seconds*60
|table body.totalTime, body.seconds, body.minutes

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...