Splunk Enterprise Security

calculate the difference between current time and Last event time and then display the difference in days

staparia
Explorer

I have the below query to calculate events not reporting for last 24 hours. I want to calculate the difference between current time and Last event time and then display the difference in days. This is the query i have. Somehow it diff field is empty. Please help

| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| convert ctime(lastTime) as Last_Time timeformat="%Y/%m/%d %H:%M" | eval diff=tostring(now() - Last_Time,"duration")
| fields sourcetype Last_Time diff
| sort -Last_Time

0 Karma
1 Solution

to4kawa
Ultra Champion
| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| eval diff=tostring(now() - lastTime,"duration")
| fields sourcetype lastTime diff
| sort - lastTime
|eval lastTime = strftime(lastTime,"%Y/%m/%d %H:%M" )

you should change time format at last.

View solution in original post

0 Karma

to4kawa
Ultra Champion
| metadata type=sourcetypes index=*
| search sourcetype!=*too_small
| where lastTime < (now() - 86400)
| eval diff=tostring(now() - lastTime,"duration")
| fields sourcetype lastTime diff
| sort - lastTime
|eval lastTime = strftime(lastTime,"%Y/%m/%d %H:%M" )

you should change time format at last.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...