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!

Let’s Talk Terraform

If you’re beyond the first-weeks-of-a-startup stage, chances are your application’s architecture is pretty ...

Cloud Platform | Customer Change Announcement: Email Notification is Available For ...

The Notification Team is migrating our email service provider. As the rollout progresses, Splunk has enabled ...

Save the Date: GovSummit Returns Wednesday, December 11th!

Hey there, Splunk Community! Exciting news: Splunk’s GovSummit 2024 is returning to Washington, D.C. on ...