Splunk Search

How to find the time difference between the event and the current time?

alexspunkshell
Contributor

I have " threatInfo.updatedAt" information in my logs.

I want to get an alert if the time difference between "threatInfo.updatedAt" & "_time" is more than 4 hours.

 

My Search Query

index=test "file_name"=* "threatInfo.incidentStatus"=unresolved |transaction threatInfo.updatedAt | table _time threatInfo.updatedAt file_name file_path category

 

alexspunkshell_0-1650880195926.png

 

Labels (4)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust
| eval updatedat=strptime(threatInfo.updatedAt,"i never remember those formats ;)")
| where abs(_time-updatedat)<4*3600

I really can never remember those time format specifiers. 

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Link to those: https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables

In your case: "%Y-%m-%dT%H:%M:%S.%6Q%Z" or same in shorter format "%FT%T.%6Q%Z"

r. Ismo

PickleRick
SplunkTrust
SplunkTrust

Thanks. 🙂 As usual, I was typing it on my tablet and it's very inconvenient to switch between different tabs there.

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 ...