Splunk Search

Сombine several sourcetypes into one table сonsidering that one of the sourcetypes may not exist

emerald
Engager

I want to combine several sources into one table and I'm using this search:

 

sourcetype="firstsourcetype" somefield="value" | head 50 | join uuid [search sourcetype="secondsourcetype"] | join uuid [search sourcetype="thirdsourcetype"]

 

But if one of the sourcetypes doesn't exist, I don't get the data at all. I'm looking for a way to fix it.
Thanks in advance

 

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @emerald, you can fix by using join type=left as below;

sourcetype="firstsourcetype" somefield="value" | head 50 | join type=left uuid [search sourcetype="secondsourcetype"] | join type=left uuid [search sourcetype="thirdsourcetype"]

 

But, better/faster approach is using stats; you can add required fields with values function,

(sourcetype="firstsourcetype" somefield="value" ) OR sourcetype="secondsourcetype" OR sourcetype="thirdsourcetype" 
| stats values(somefield) by uuid 

 

If this reply helps you, upvote is appreciated.

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @emerald, you can fix by using join type=left as below;

sourcetype="firstsourcetype" somefield="value" | head 50 | join type=left uuid [search sourcetype="secondsourcetype"] | join type=left uuid [search sourcetype="thirdsourcetype"]

 

But, better/faster approach is using stats; you can add required fields with values function,

(sourcetype="firstsourcetype" somefield="value" ) OR sourcetype="secondsourcetype" OR sourcetype="thirdsourcetype" 
| stats values(somefield) by uuid 

 

If this reply helps you, upvote is appreciated.

If this reply helps you an upvote and "Accept as Solution" is appreciated.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...