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!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...