Splunk Search

Combine two separate indexes based on any permutation of the matching ID fields

eyeglassescase
Observer

Hi Splunk Community,

 

I need help to write a Splunk query to join two different indexes using any Splunk command that will satisfy the logic noted below.

 

Two separate ID fields in Index 2 must match two separate ID fields in Index 1 using any permutation of index 2’s three ID fields. Here is an outline of the logic below.

 

Combine index 1 record with index 2 record into a single record when any matching condition is satisfied below:

(ID_1_A=ID_2_A AND ID_1_B=ID_2_B)

OR

(ID_1_A=ID_2_A AND ID_1_B=ID_2_C)

OR

(ID_1_A=ID_2_B AND ID_1_B=ID_2_A)

OR

(ID_1_A=ID_2_B AND ID_1_B=ID_2_C)

OR

(ID_1_A=ID_2_C AND ID_1_B=ID_2_A)

OR

(ID_1_A=ID_2_C AND ID_1_B=ID_2_B)

Sample Data:

 

Index 1:

-----------------------

|ID_1_A |ID_1_B|

------------------------

|123       |345      |

------------------------

| 345      |123      |

------------------------

 

Index 2:

________________________

|ID_2_A   | ID_2_B   | ID_2_C|

----------------------------------------

|123         |345           |999       |

----------------------------------------

|123         |999           |345       |

----------------------------------------

|345         |123            |999      |

----------------------------------------

|999         |123           | 345       |

----------------------------------------

| 345       | 999           |123        |

----------------------------------------

 

Any help would be greatly appreciated.

 

Thanks.

 

Labels (4)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval correlation1=coalesce(ID_1_A, ID_2_A)
| eval correlation2=coalesce(ID_1_B, ID_2_B)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
| eval correlation1=coalesce(ID_1_A, ID_2_A)
| eval correlation2=coalesce(ID_1_B, ID_2_C)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
| eval correlation1=coalesce(ID_1_A, ID_2_B)
| eval correlation2=coalesce(ID_1_B, ID_2_A)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
| eval correlation1=coalesce(ID_1_A, ID_2_B)
| eval correlation2=coalesce(ID_1_B, ID_2_C)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
| eval correlation1=coalesce(ID_1_A, ID_2_C)
| eval correlation2=coalesce(ID_1_B, ID_2_A)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
| eval correlation1=coalesce(ID_1_A, ID_2_C)
| eval correlation2=coalesce(ID_1_B, ID_2_B)
| eventstats values(index1data) as index1data, values(index2data) as index2data by correlation1 correlation2
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...