Splunk Search

How do you find details about results using the set command with a diff argument?

aa274t
New Member

I am using two searches

Search1 search 2
1 1
2 2
3 3
5 4

Using set diff gives me the result. I don't want to use join.

set diff [search index=ABC sourcetype=PQRS| stats count by x_orderno | fields - count]
[search index=DEF sourcetype=WXYZ| stats count by x_orderno | fields - count]

x_orderno
5
4

I want the result as
x_orderno sourcetype
5 PQRS
4 WXYZ

Kindly suggest.

TIA

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

| makeresults 
| eval raw="sourcetype=PQRS,x_orderno=1 sourcetype=WXYZ,x_orderno=1 sourcetype=PQRS,x_orderno=2 sourcetype=WXYZ,x_orderno=2 sourcetype=PQRS,x_orderno=3 sourcetype=WXYZ,x_orderno=3 sourcetype=PQRS,x_orderno=5 sourcetype=WXYZ,x_orderno=4" 
| makemv raw 
| mvexpand raw 
| rename raw AS _raw 
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| stats dc(sourcetype) AS sourcetypeCount values(sourcetype) AS sourcetype BY x_orderno
| where sourcetypeCount==1
| table x_orderno sourcetype

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

| makeresults 
| eval raw="sourcetype=PQRS,x_orderno=1 sourcetype=WXYZ,x_orderno=1 sourcetype=PQRS,x_orderno=2 sourcetype=WXYZ,x_orderno=2 sourcetype=PQRS,x_orderno=3 sourcetype=WXYZ,x_orderno=3 sourcetype=PQRS,x_orderno=5 sourcetype=WXYZ,x_orderno=4" 
| makemv raw 
| mvexpand raw 
| rename raw AS _raw 
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| stats dc(sourcetype) AS sourcetypeCount values(sourcetype) AS sourcetype BY x_orderno
| where sourcetypeCount==1
| table x_orderno sourcetype
0 Karma

aa274t
New Member

Awesome. Thanks 🙂

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

(index=ABC sourcetype=PQRS) OR (index=DEF sourcetype=WXYZ)
| stats values(sourcetype) as sourcetype by x_orderno
| where mvcount(sourcetype)=1
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...