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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...