Splunk Search

How to search two indexes to find if an event in index B does not occur within certain time range of an event in index A?

patelaa
Explorer

I hope the following makes sense...I have two indexes for separate application logs, index A and index B. I need help writing a search that will show me if a certain event in index B does not occur within 24 hours of an event in index A.

The search to find the event in index A is:

index=indexA sourcetype=sourcetype Network_Address="1.1.1.1" OR Network_Address="2.2.2.2" OR Network_Address="3.3.3.3" 
| stats values(src) values(time) by user

The search to find the event in index B is:

index=indexB "eventCode" | stats values(id) values(time) AS id by user

So basically I want the search to show me all users who have an event in index A, along with the src and time from each event, but don't have an event in index B within 24 hours of the index A event.

Tags (3)
1 Solution

mreynov_splunk
Splunk Employee
Splunk Employee

I would suggest to use outputlookup to store results of the first query, then do the second search and use eval to make the calculation

View solution in original post

mreynov_splunk
Splunk Employee
Splunk Employee

I would suggest to use outputlookup to store results of the first query, then do the second search and use eval to make the calculation

patelaa
Explorer

Using mreynov's suggestion I piped the search in index A to a lookup table then used the following search to get my desired results

|inputlookup lookUpName.csv
| search NOT [search index=indexB "eventCode"
| fields user]

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
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 ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...