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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...