Splunk Search

How to count total row number of non-zero field?

LearningGuy
Builder


How to count total row number of non-zero field?
Thank you in advance

Below is the data set:

ipVulnerabilityScore
ip1Vuln10
ip1Vuln23
ip1Vuln34
ip2Vuln40
ip2Vuln50
ip2Vuln67



| stats count(Vulnerability) as Total_Vuln, countNonZero(Score) as Total_Non_Zero_Vuln by ip
Is there a function similar to countNonZero(Score) to count row number of non-zero field in Splunk?

With my search above, I would like to have the following output:

ipTotal_VulnTotal_Non_Zero_Vuln
ip132
ip231



Labels (1)
0 Karma
1 Solution

LearningGuy
Builder

I think I just figured it out
This search worked when I tried it...  Please suggest..... Thanks
| stats count(Vulnerability) as Total_Vuln, count(eval(Score>0)) as Total_Non_Zero_Vuln by ip

View solution in original post

0 Karma

LearningGuy
Builder

I think I just figured it out
This search worked when I tried it...  Please suggest..... Thanks
| stats count(Vulnerability) as Total_Vuln, count(eval(Score>0)) as Total_Non_Zero_Vuln by ip

0 Karma

inventsekar
SplunkTrust
SplunkTrust

Yep, thats a valid and nice SPL(the eval(score>0)). 

or
the "!=" also should do the trick... 

| stats count(eval(score!=0)) as Total_Non_Zero_Vuln by ip 


the stats, eval commands give us so many options, very nice!

 

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...