Splunk Search

how to exclude a events in the search query if the events is present in the other index

Rajiv_splunk
Path Finder

I have a scenario where events are coming from one index =sample field= status as status 1, 2, 3, 4 , and 5. I have to exclude all the status which is present in the other index =services  as status 1 and 2. How can i achieve it.

I am trying the below query in the base query to exclude  but it is not working

index=sample status=*

''''''base query"'''

 

|search NOT

[search index="service"   earliest=-24h latest=now  |search status IN (1,2)| table  status]

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Rajiv_splunk ,

please try this:

index=sample status=*
NOT [ search 
     index="service" earliest=-24h latest=now  status IN (1,2)
     | table  status ]

don't use the search command after the main search, you'll have more performant searches.

if the two searches don't match, check if the values in the subsearch are compatible with the values of the main earch.

Ciao.

Giuseppe

0 Karma
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!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

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