Splunk Search

inputlookup - count of values including Null

warren
Explorer

Hello,

I have a lookup file and I would like to use it to search a dataset and return a table showing each entry in the lookup file with a count of their number of matches in the main dataset including displaying the entries from the lookup file which have a null value.

 

I've tried a number of techniques, the closet I have come is:

dataFeedTypeId=AS
[| inputlookup approvedsenders
| fields Value
| return 1000 $Value]
| stats count as cnt_sender by sender

But this only shows the lookup fileentries with non-zero values (n.b. I am manually adding 1000 to the return to make it work, that's a different problem)

I have also tried:

dataFeedTypeId=AS [ | inputlookup approvedsenders | fields Value]
| stats count as cnt_sender by Value
| append
[ inputlookup approvedsenders | fields Value]
| fillnull cnt_sender
| stats sum(cnt_sender) as count BY Value

This shows all the values in the lookup file but shows a zero count against each one. 

Thank you in advance.

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

If sender is the field in the dataset, then it should be something like this

dataFeedTypeId=AS [ | inputlookup approvedsenders | fields Value | rename Value as sender]
| stats count as cnt_sender by sender
| append
[ inputlookup approvedsenders | fields Value | rename Value as sender]
| fillnull cnt_sender
| stats sum(cnt_sender) as count BY sender

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Your second search should work - is it just a simple lookup e.g. not wildcard or CIDR match? Do you have a typo in your actual search?

0 Karma

warren
Explorer

@ITWhisperer at the moment it is just a simple lookup, there are values in the table which match the log data exactly. The first example does return the correct results (without the null values).

Value is the information from the lookup file. 

sender is the information from the main dataset

cnt_sender is a variable used within the code

Is that how it should be?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If sender is the field in the dataset, then it should be something like this

dataFeedTypeId=AS [ | inputlookup approvedsenders | fields Value | rename Value as sender]
| stats count as cnt_sender by sender
| append
[ inputlookup approvedsenders | fields Value | rename Value as sender]
| fillnull cnt_sender
| stats sum(cnt_sender) as count BY sender

warren
Explorer

@ITWhisperer Thank you so much, that has returned the results I was expecting. 

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...