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!

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...

Event Series: Mastering AI Tokenomics and Splunk Agent Observability

Beyond the Black Box: Correlating AI Performance and Tokenomics with Splunk Agent Observability   As ...

span_metrics: The OpenTelemetry-Idiomatic Way to See Inside Your Services

You open a trace in Splunk Observability Cloud and everything looks fine. One root span, order-pipeline, with ...