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!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

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

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...