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
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...