Splunk Search

How to get Uptime in Days

priya1926
Path Finder

My output format is 20220129054235.496380-300

I need to convert the value in bold to normal and find the difference of that to now() ie., epoch time.  this will give the uptime in days


Labels (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

Hi

here is one way

| makeresults 
| eval time="20220129054235.496380-300"
| eval epoch = strptime(time, "%Y%m%d%H%M%S.%6Q%z")
| eval time2 = strftime(epoch, "%F %T")
| eval UpTime = tostring(round(now()-epoch), "duration")

If you want to calculate with UpTime then you need to convert it by yourself as usually to get days, hours, mins and seconds from it.

r. Ismo 

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

Hi

here is one way

| makeresults 
| eval time="20220129054235.496380-300"
| eval epoch = strptime(time, "%Y%m%d%H%M%S.%6Q%z")
| eval time2 = strftime(epoch, "%F %T")
| eval UpTime = tostring(round(now()-epoch), "duration")

If you want to calculate with UpTime then you need to convert it by yourself as usually to get days, hours, mins and seconds from it.

r. Ismo 

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...