Splunk Search

Compare data between multi column tables and find difference

renSplunk
New Member

Hi,

I have a query that gives a table of records satisfying certain condition. Have another query that gives the same result fields, but with a different search string.
Now I want to find the ones that are present in first result and not in the second one
Query1 : index=mail sourcetype=testmail "Search condition 1" | table field1 field2 field3 | dedup field1 field2 field3
Query2 : index=mail sourcetype=testmail "Search condition 2" | table field1 field2 field3 | dedup field1 field2 field3
How do I find the one that is only present in Query 1 and then list it as a table with all 3 fields?

Labels (1)
0 Karma

to4kawa
Ultra Champion
index=mail sourcetype=testmail "Search condition 1" OR "Search condition 2"
| eval condition1=if(searchmatch("Search condition 1"),"y","n")
| eval condition2=if(searchmatch("Search condition 2"),"y","n")
| table field1 field2 field3 condition*
0 Karma

manjunathmeti
Champion

You can use NOT,

 index=mail sourcetype=testmail "Search condition 1"  NOT "Search condition 2" | table field1 field2 field3 | dedup field1 field2 field3

 

0 Karma

renSplunk
New Member

I tried it, but it gives me only the first search results. What I want is to search for both and then find the difference between them

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!

Event Series: Splunk Observability Metrics Cost Optimization

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...