Splunk Search

Updating search for a better accuracy when doing an eval

trevorQmulos
New Member

I have the current search right now but am getting inaccurate numbers due to an issue with my search. I would like to rearrange the search so that I can sum the cvss_base_score instead of doing the division on every event and then summing all those values. I have tried to move the stats sum prior to the eval but then I get no results back from the search.

index=network sourcetype=nessus severity!=informational signature=Windows OR signature=Adobe OR signature=Java OR signature_family="Windows : Microsoft Bulletins" OR signature_family="Red Hat Local Security Checks" OR signature="Google Chrome*" OR signature="Firefox*" OR signature="MS*" OR signature="Flash Player*" OR signature="Solaris*"

| dedup dest_dns signature_id

| eventstats dc(dest_dns) as TotalDNS

| bin span=1mon _time

| eval PatchScore=cvss_base_score/TotalDNS

| stats sum(PatchScore) AS "Avg Host Patch Score" by _time

Tags (3)
0 Karma
1 Solution

sundareshr
Legend

Try this

index=network sourcetype=nessus severity!=informational signature=Windows OR signature=Adobe OR signature=Java OR signature_family="Windows : Microsoft Bulletins" OR signature_family="Red Hat Local Security Checks" OR signature="Google Chrome*" OR signature="Firefox*" OR signature="MS*" OR signature="Flash Player*" OR signature="Solaris*" 
| dedup dest_dns signature_id 
| eventstats dc(dest_dns) as TotalDNS 
| bin span=1mon _time 
| stats sum(cvss_base_score) as TotalScore max(TotalDNS) as TotalDNS by _time
| eval "Avg Host Patch Score"=TotalScore/TotalDNS 

View solution in original post

sundareshr
Legend

Try this

index=network sourcetype=nessus severity!=informational signature=Windows OR signature=Adobe OR signature=Java OR signature_family="Windows : Microsoft Bulletins" OR signature_family="Red Hat Local Security Checks" OR signature="Google Chrome*" OR signature="Firefox*" OR signature="MS*" OR signature="Flash Player*" OR signature="Solaris*" 
| dedup dest_dns signature_id 
| eventstats dc(dest_dns) as TotalDNS 
| bin span=1mon _time 
| stats sum(cvss_base_score) as TotalScore max(TotalDNS) as TotalDNS by _time
| eval "Avg Host Patch Score"=TotalScore/TotalDNS 

trevorQmulos
New Member

Do you guys see a way to contain that number by the bin span or due to the eval needing to come after the sum or am I forced to use the highest distinct count?

0 Karma

sundareshr
Legend

Try moving the bin to before the eventstats and add a by _time to eventstats.

 index=network sourcetype=nessus severity!=informational signature=Windows OR signature=Adobe OR signature=Java OR signature_family="Windows : Microsoft Bulletins" OR signature_family="Red Hat Local Security Checks" OR signature="Google Chrome*" OR signature="Firefox*" OR signature="MS*" OR signature="Flash Player*" OR signature="Solaris*" 
 | dedup dest_dns signature_id 
 | bin span=1mon _time 
 | eventstats dc(dest_dns) as TotalDNS by _time
 | stats sum(cvss_base_score) as TotalScore max(TotalDNS) as TotalDNS by _time
 | eval "Avg Host Patch Score"=TotalScore/TotalDNS
0 Karma

trevorQmulos
New Member

Worked like a charm. Thanks again for the help.

Is there anyway for the MAX(dest_dns) to be specific to the month... for instance with the search, it will take that MAX and apply it to every month regardless of the max during that time frame so results are off for months where the number was low.

0 Karma

somesoni2
Revered Legend

The field _time is not available after stats sum(cvss_base..... Did you miss by _time there?

0 Karma

sundareshr
Legend

Good catch. See updated.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...