Splunk Search

How to find differences between two saved searches based on a common field?

Splunk_321
Path Finder

I have two saved searches 

1) Metrics-Location-Client -- Gives LocationId, Client_Name as output

2) Matched-Locations -- Gives LocationId

I want to get count of locationIds by Client_Name which are present in Metrics-Location-Client but not in Matched-Locations.

Below is the one which I am trying but its not working it seems.

| savedsearch "Metrics-Location-Client"
| join Left=L Right=R where L.LocationId!=R.LocationId
[ savedsearch "Matched-Locations" ]
| stats count(L.LocationId) as MonitoringCalls by L.Client_Name

I have tried set diff as well, but not working

| set diff
[ savedsearch "Metrics-Location-Client" ]
[ savedsearch "Matched-Locations" ]
| stats count(LocationId) by Client_Name

Any help would be appreciated!

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

"not working" is not a problem statement.  What does your code give you?  Why does the result not satisfy your requirement (in terms of sample data)?

Perhaps more importantly, as many - me included, will tell you, try not to use join or set operations if you can avoid it.  Do the two saved search work on the same set of data?  Is there some way to fetch (typically using search command) all raw data needed for the saved searches in one raw search?  Does one (or both) not contain generating command? (For this reason, it is often not a good idea for macros to contain generating command.)  Join and set are particularly inefficient, whereas Splunk stats are extremely efficient.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...