Splunk Search

How can one combine two fields with the same values- but different field names- to aggregate data from multiple sourcetypes?

amcb90
Engager

I have two fields with the same values but different field names.

index= network
sourcetype= firewall
The source IP field is "src"
sourcetype= logins
The source IP field is "src_ip"

I would like to be able to combine the results of both in a stats table to have a line item contain info from both sourcetypes:
example:

index=network sourcetype=firewall OR sourcetype=logins |(Whatever I need to do to combine two fields into one) | stats values(username) as Usernames, values(alert) as Alerts by (NEW_Source_IP_Field_Name)
0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

You could use coalesce in your search:

[YOUR BASE SEARCH]
| eval newfield=coalesce(field1,field2)

This will merge the values of both fields into one field.

Vijeta
Influencer

@ambc90 Try this -

index=network sourcetype=firewall OR sourcetype=logins |rename src_ip as src| stats values(username) as Usernames, values(alert) as Alerts by src

OR you can use

index=network sourcetype=firewall OR sourcetype=logins |eval src=coalesce(src,src_ip)| stats values(username) as Usernames, values(alert) as Alerts by src
0 Karma

Sukisen1981
Champion
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...