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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...