Splunk Search

How do you get all matching and non-matching rows from a Splunk search and lookup?

Shashank_87
Explorer

Hi,

I am working on a query where I have to match the responseCode from the search to the responseCode in a lookup I created. That lookup contains the responseCode and its description.

Now there are a few cases where the responseCode in the search does not match to anything in the lookup table. I want the count of all responseCodes. If it matches in the lookup then with its description, and if it doesn't match, then the description would be null, but I want the count.

My current search is not giving the count of the unmatched responseCode —

index="test" sourcetype="test_log" 
| dedup time,host,source,_raw 
| lookup Response_Codes_Desc ResponseCode
| stats count by ResponseCode Description
| sort - count

Please could someone help on this?

0 Karma
1 Solution

chrisyounger
SplunkTrust
SplunkTrust

what about this:

index="test" sourcetype="test_log" 
| dedup time,host,source,_raw 
| lookup Response_Codes_Desc ResponseCode
| eval Description = coalesce(Description, "")
| stats count by ResponseCode Description
| sort - count

View solution in original post

0 Karma

jvishwak
Path Finder

Check if this helps:
index="test" sourcetype="test_log"
| dedup time,host,source,_raw
| lookup Response_Codes_Desc ResponseCode
| eval NoMatch = if(isnull(Description), 1, 0)
| eventstats sum(NoMatch) as NoMatch, sum(eval(if(NoMatch = 0, 1, 0))) as MatchAvailable

0 Karma

chrisyounger
SplunkTrust
SplunkTrust

what about this:

index="test" sourcetype="test_log" 
| dedup time,host,source,_raw 
| lookup Response_Codes_Desc ResponseCode
| eval Description = coalesce(Description, "")
| stats count by ResponseCode Description
| sort - count
0 Karma

Shashank_87
Explorer

That is perfect Chris. Thank you very much. 🙂

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...