Splunk Search

Alternative to Joins

vikasreddy
Explorer

I have 2 indexes say (A1 and A2) I have Fields a,b,c,d in index A1, In the index A2 I have fields b,e,f,g . I need to pull the data of the e,f,g fields from the A2 index if "b" values present in the both the index .I don't want to use the joins. Any way we can implement this ?.
Here is the sample search , what I have written but no luck ..
(index=A1 fields a,b,c,d) OR (index=A2 fields b,e,f,g)
| eval E=if(b==b,e,null())
| eval F=if(b==b,f,null())
| eval G=if(b==b,g,null())
| table E,F,G,b

Any help would be great ..Thanks 🙂

0 Karma

MuS
Legend
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Can you please try this?
(index=A1) OR (index=A2) | stats values(a) as a values(c) as c values(d) as d values(e) as e values(f) as f values(g) as g by b | where ( isnotnul(e) OR isnotnul(f) OR isnotnul(g) )

0 Karma

somesoni2
Revered Legend

Try like this. This will give results for values of field b which is present in both indexes

(index=A1) OR (index=A2)
| fields a,b,c,d,e,f,g
| stats values(a) as a values(c) as c values(d) as d values(e) as e values(f) as f values(g) as g dc(index) as indexes by b
| where indexes=2

cmerriman
Super Champion

try something like this:

(index=A1 a=* b=* c=* d=*) OR (index=A2 b=* e=* f=* g=*)
|stats values(e) as e values(f) as f values(g) as g by b

it will give you the values of e, f, and g for every b value

richgalloway
SplunkTrust
SplunkTrust

The stats command can replace join.

(index=A1 a=* b=* c=* d=*) OR (index=A2 b=* e=* f=* g=*) | stats values(c) as c values(d) as d values(e) as e values(f) as f values(g) as g by b | table e f g b
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...