Splunk Search

How to compare a field from one sourcetype with another sourcetype then return the result in a new field?

Zerophage
New Member

Hello,

Hoping someone can help, I'm new to Splunk.

Lets say I have the following source types:
"event_alert" - contains an event with a username
"user_info" - contains information about users

Is there a way I can run a search which returns "event_alert" but with extra fields that are matched from "user_info". So I'm looking into "user_info" for a user name and if it exists, it then returns business unit, etc.

I thought of using eval but I cannot figure out how to reference fields from different sourcetypes something like the below doesn't work:

eval unit = if ("event_alert.user" == "user_info.username",business_unit,"unknown") 

Hope my question makes sense, let me know if i can elaborate.

Tags (3)
0 Karma

koshyk
Super Champion

hi, the efficient way to do this is (Assuming user and username are NOT present in the same sourcetype)

index=* (sourcetype=event_alert OR sourcetype=user_info) | eval unit = if (user == username,business_unit,"unknown") | stats count by unit

====

# Real life example would be
index=_internal (sourcetype=splunkd OR sourcetype=splunkd_access) |  eval unit=if(service_maxSizes==roll_hotBkt ,"hit","miss")| stats count by unit
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...