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!

Announcing Scheduled Export GA for Dashboard Studio

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

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 GA in US-AWS!

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