Splunk Search

LOOKUP and NULL values

shelleysm
Loves-to-Learn

Hello, I am new-ish to Splunk and had a question regarding the use of a lookup table and wanting to include all values listed in a lookup table in search output even when there are no events related.  To summarize, I have a lookup file that correlates a server name with an environment name:

host, EnvName

server1, EnvA

server2, EnvB

serverN,EnvN...

I am trying to show the number of events per day per server and my issue is that when there are no events for a server during the timeframe, the server is not listed in the output.  

index=index_name sourcetype=sourcetype_name | lookup lookup_name host OUTPUT EnvName | chart count by ....

With this search, only values with events will be returned.  Is there a way to include the values in the lookup that do not have any events during this timeframe?  Thanks.

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this (untested)

index=index_name sourcetype=sourcetype_name 
| stats count by ....
| inputlookup append=t lookup_name 
| fillnull value=0 count 
| rename host as EnvName 
| chart sum(count) as count by ....

You might need additional renames and/or fillnulls depending on your data/lookup table, but essentially you are appending zero counts for everything in your lookup and then adding these to the existing counts (if there were any)

0 Karma
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 ...