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!

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

🍂 Fall into November with a fresh lineup of Community Office Hours, Tech Talks, and Webinars we’ve ...

Transform your security operations with Splunk Enterprise Security

Hi Splunk Community, Splunk Platform has set a great foundation for your security operations. With the ...

Splunk Admins and App Developers | Earn a $35 gift card!

Splunk, in collaboration with ESG (Enterprise Strategy Group) by TechTarget, is excited to announce a ...