Splunk Search

How to Combine Events with matching data

BlueWombat45
New Member

Hi, I have a union'ed search where I am wanting to link different events based on fields that have matching values.
My search looks like this:
| union
[search message=*
| spath Field1
| spath Field2]
[search city=*
| spath FieldA 
| spath FieldB]
| table Field1 Field2 FieldA FieldB

My current output looks like this:

Field1Field2FieldAFieldB
JohnBlue  
  BlueOhio
  YellowWyoming

 

However I need a way to link Field1 to FieldB if Field2=FieldA, where the output would look something like this: 

Field1Field2FieldAFieldB
JohnBlueBlueOhio
  YellowWyoming


If there is a way to do something like this, please let me know, even if I need to create new fields. The excess FieldA and FieldB are unimportant if there is not a matching Field2. 

please help, please

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
message=* OR city=*
| eval Field2=coalesce(Field2, FieldA)
| stats values(*) as * by Field2
| where isnotnul(Field1)
0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...