Splunk Search

How to only return subsearch results which are not available on main search?

splunkxorsplunk
Explorer

I have two indexes which include same data in a different fields as seen below. 

index1 -- user, fileName, ...etc

index2 -- event.file, actor

user = actor and fileName = event.file

The following search gives me if a user and their file in index2 is available in the index1, but I dont need this since I know they should be included in index1

What I am trying to find is : If a user and their file in index2 is NOT available in the index1, I wanna list them out. 

Thanks for help

index="index1"

[search index="index2" "event"=event2 event.file="something_*"

| table event.file, actor
| rename event.file as fileName, actor as user
]

| table actor

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Swap the searches and you should get what you're looking for.

index="index2"
NOT [search index="index1" "event"=event2 fileName="something_*"
| fields fileName user
| rename fileName as event.file, user as actor
| format
]
| table actor
---
If this reply helps you, Karma would be appreciated.

View solution in original post

splunkxorsplunk
Explorer

Thanks for solution recommendations!

My initial pivot point should be index2 since index1 includes all files and actors. if a user and associated file is available in index2 but not index1, that is what I am looking for. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Swap the searches and you should get what you're looking for.

index="index2"
NOT [search index="index1" "event"=event2 fileName="something_*"
| fields fileName user
| rename fileName as event.file, user as actor
| format
]
| table actor
---
If this reply helps you, Karma would be appreciated.
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!

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

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...