Splunk Search

Manipulating eval and stats to get desired results

Robbie1194
Communicator

Hi guys,

I'm trying to search our Qualys vulnerability data to the average cvss score for all vulnerabilities with the serverity high or critical, however, I want my average to be done over ALL of our qualys assets, not just the devices that have a high or critical vulnerability. For example,

| from datamodel:"Vulnerabilities"."Vulnerabilities"
| stats dc(IP) as IP_count, values(severity) as severity, values(cvss) as cvss
| search severity=high OR severity=critical
| stats values(IP_count) as IP_count, sum(cvss) as cvss by severity
| eval average = (cvss/IP_count)
| table average, severity

I've tried using the above search to distinct count ALL IP's then once I've got that value, i've tried to filter to only the the IPs that have high or critical severity vulns. I've then tried to use an eval statement to average this to give me my desired end result but nothing seems to be working because of the way that Splunk passes through it's stats values. I've also tried using appendcols and couldn't get it working either. Does anyone have any ideas/suggestions on how if/how this is possible?

Cheers!

0 Karma

woodcock
Esteemed Legend

Try this:

| from datamodel:"Vulnerabilities"."Vulnerabilities" 
| multireport
[ search severity=high OR severity=critical  | stats dc(IP) AS severe ]
[ stats dc(IP) AS total ]
| eval average = severe/total
0 Karma

somesoni2
Revered Legend

Give this a try

| from datamodel:"Vulnerabilities"."Vulnerabilities" 
| statsvalues(cvss) as cvss by severity IP
| eval higherSevcvss=if(severity="high" OR severity="critical",cvss,null())
| stats dc(IP) as IP_count, sum(higherSevcvss) as cvss by severity
| eval average = (cvss/IP_count) 
| table average, severity
0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...