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.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...