Splunk Search

time difference of events

msachdeva3
Explorer

eval test_time = time() - _time | search (test_time > 1800 AND test_time < 86400)|

I'm trying to see if the events in my logs(when i run query should be more than 30 mins & less than 24 hrs old) from the time they logged?

is the condition right?

Tags (1)
0 Karma

DalJeanis
Legend

gpradeepkumarreddy's answer is probably the most useful way to do that.

If you wanted to do it in code, your code is close to correct as far as it goes, since epoch time is calculated in seconds. However, you probably want to use the now() function rather than time(), since it will give a single result for the entire search, as opposed to being calculated at a different microsecond for each event.

0 Karma

pradeepkumarg
Influencer

You can use the time picker or mention earliest and latest as below in your search


earliest=-24h latest=-30m

Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...