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!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...