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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...