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!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...