Splunk Search

How can we join two sourcetypes together that have a common field?

Hema_Nithya
Explorer

How can we join fields of two source types, when one field is the same in both source types?

0 Karma

cmerriman
Super Champion

try this.

index=itsm sourcetype=tsm_filespaces OR sourcetype=tsm_nodes|stats values(*) as * by node_name| dedup node_name,filespace_name | table node_name, platform_name, filespace_name,backup_end,host
0 Karma

Hema_Nithya
Explorer

yes , I used Join ...

index=itsm sourcetype=tsm_filespaces |join node_name [search sourcetype=tsm_nodes] | dedup node_name,filespace_name | table node_name, platform_name, filespace_name,backup_end,host
0 Karma

somesoni2
Revered Legend

Do node_name and filespace_name fields available in same sourcetype (single) OR both sourcetypes?

0 Karma

niketn
Legend

There could be multiple ways

Easiest to do might be through transaction

sourcetype="srcType1" OR sourcetype="srcType2" commonField=*
| transaction commonField
| table _time, eventcount, duration, _raw

However, stats might perform better based on use case. You will have to use combinations of first(), last(), min(), max() or values() etc for various fields that you want to work on after correlation

sourcetype="srcType1" OR sourcetype="srcType2" commonField=*
| stats count as eventcount by commonField
| search eventcount>1

You can also use append, appendcols, appendpipe, join,lookup etc based on your needs.

Refer to the following event correlation documentation for deciding on your choice: http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

niketn
Legend

As per your example

index=itsm sourcetype=tsm_filespaces  OR sourcetype=tsm_nodes node_name=* 
|stats values(filespacename) as filespacename values(platform_name) as platform_name values(backup_end) as backup_end values(host) as host by nodename 
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

somesoni2
Revered Legend

There are various methods for it and which one will be best depends upon the output that you expect after joining them. Could you explain more on what is your end goal after joining those two sourcetype's data?

0 Karma

renjith_nair
Legend

Are you looking for something like

(sourcetype=A OR sourcetype=B) commonfield=<value>

OR

(sourcetype=A OR sourcetype=B) |stats values(commonfield)
Happy Splunking!
0 Karma

cmerriman
Super Champion

I want to make sure I understand.

You have Sourcetype A and Sourcetype B and both of them have Field X and you want to join these two sourcetypes together based on Field X?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...