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
SplunkTrust
SplunkTrust
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
SplunkTrust
SplunkTrust

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!

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 ...