Splunk Search

How to replace values outputted from a stats with lookup table values?

dritjon
Path Finder

I've done a simple search like this:

index=fw_cisco | stats dc(dest_ip) as NrDestIp by src_ip

I have defined a lookup file (ip_lookup) which has two colums: IPHost and DNShost. How do I replace the values of src_ip with the corresponding values of the lookup table?

I tried this

index=fw_cisco | lookup ip_lookup IPHost as src_ip OUTPUT DNSHost as resolved_src | stats dc(dest_ip) as NrDestIp by src_ip, resolved_src

But it creates two columns, and also misses the values of src_ip that dont have a matching IPHost in the lookup table.

Labels (1)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index=fw_cisco 
| lookup ip_lookup IPHost as src_ip OUTPUT DNSHost as resolved_src 
| eval resolved_src=coalesce(resolved_src, src_ip)
| stats dc(dest_ip) as NrDestIp by src_ip, resolved_src

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
index=fw_cisco 
| lookup ip_lookup IPHost as src_ip OUTPUT DNSHost as resolved_src 
| eval resolved_src=coalesce(resolved_src, src_ip)
| stats dc(dest_ip) as NrDestIp by src_ip, resolved_src
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...