Splunk Search

How do you Join two searches based on lookup values?

ADRIANODL
Explorer

Hi folks,

I have 2 searches that return equivalent values based on the result of a lookup, as such:

Search 1

index=alpha tag=email SenderAddress=*@domain.com 
| table *Email_Address*, Name 

Search 2

index=alpha sourcetype="activities"
| spath
| search "tags{}.category_id"=USBTFR
|rex field=User_Name "(?\w{3,6})" 
|eval User_Name=upper(User_Name) 
|lookup tablename LogonID as User_Name OUTPUT *EmailAddress*

How can I join the result of the two searches based on the EmailAddress field?

0 Karma
1 Solution

woodcock
Esteemed Legend

Like this:

index=alpha ((tag=email SenderAddress=*@domain.com) OR (index=alpha sourcetype="activities"))
| spath
| search "tags{}.category_id"=USBTFR OR (tag=email SenderAddress=*@domain.com)
| rex field=User_Name "(?\w{3,6})" 
| eval User_Name=upper(User_Name) 
| lookup tablename LogonID AS User_Name OUTPUT EmailAddressOther
| eval EmailAddress=coalesce(EmailAddress, EmailAddressOther)
| fields - EmailAddressOther And Perhaps Other Fields Too
| stats values(*) AS * BY EmailAddress

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

index=alpha ((tag=email SenderAddress=*@domain.com) OR (index=alpha sourcetype="activities"))
| spath
| search "tags{}.category_id"=USBTFR OR (tag=email SenderAddress=*@domain.com)
| rex field=User_Name "(?\w{3,6})" 
| eval User_Name=upper(User_Name) 
| lookup tablename LogonID AS User_Name OUTPUT EmailAddressOther
| eval EmailAddress=coalesce(EmailAddress, EmailAddressOther)
| fields - EmailAddressOther And Perhaps Other Fields Too
| stats values(*) AS * BY EmailAddress
0 Karma

ADRIANODL
Explorer

Thanks for the prompt response folks, however I'm looking to return calculated values from both indexes. I'll create another question to include it.

0 Karma

bangalorep
Communicator

Does using |join EmailAddress not provide the search you want?

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...