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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...