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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...