Splunk Search

Left Outer Join Using NOT clause

petem3
New Member

I'm trying to identify arrangement's in one data source that do not exist in another data source. One of the sources has multiple indexes, but assume this should not cause a problem. I'm trying to use the NOT clause instead of a JOIN clause. The query returns values in both sources; any ideas?

index=A
| RENAME AR_ID as arrangementId
| dedup arrangementId
| fields arrangementId
NOT
[search index=B OR index=C OR index=D
| dedup arrangementId
| return 10000 arrangementId ]
| table arrangementId

Tags (2)
0 Karma
1 Solution

to4kawa
Ultra Champion
index=A OR index=B OR index=C OR index=D
| eval arrangementId=coalesce(AR_ID,arrangementId)
| stats dc(index) as index_count values(index) as index by arrangementId
| where dc=1 AND index="A"
| table arrangementId

or

index=A | fields AR_ID | dedup AR_ID | rename arrangementId
| append [search index=B OR index=C OR index=D
| fields arrangementId
| dedup arrangementId | eval flag="others"]
| stats values(others) as others by arrangementId
| where flag!="others"
| table arrangementId

Which is faster?

View solution in original post

0 Karma

to4kawa
Ultra Champion
index=A OR index=B OR index=C OR index=D
| eval arrangementId=coalesce(AR_ID,arrangementId)
| stats dc(index) as index_count values(index) as index by arrangementId
| where dc=1 AND index="A"
| table arrangementId

or

index=A | fields AR_ID | dedup AR_ID | rename arrangementId
| append [search index=B OR index=C OR index=D
| fields arrangementId
| dedup arrangementId | eval flag="others"]
| stats values(others) as others by arrangementId
| where flag!="others"
| table arrangementId

Which is faster?

0 Karma

petem3
New Member

The first solution was fastest; just a minor correction

where dc=1 AND index="A"

should be

where index_count=1 AND index="A".

It worked perfectly, many thanks for your help.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...