Reporting

How to achieve stats count on multiple fields?

mistydennis
Communicator

Hi all - this one is hurting my brain. I need to pull two distinct numbers from my events: one with a total count of assets, and one with a total count of assets that contain a vulnerability.

What I think it should look like is not working:

 

 

| (stats dc(AssetNames) AS TotalExternalAssets, (dc(Asset_Names) AS TotalExposedAssets | where vulnerability!="missing"))

 

 

 

How do I get these two counts out of my events?

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

That command is not a valid Splunk command

What you probably want is

| stats dc(AssetNames) AS TotalExternalAssets
        dc(eval(if(vulnerability!="missing", AssetNames, null()))) AS TotalExposedAssets

I assume the AssetNames field is the same field (not Asset_Names in the second case)

This takes the count of unique assets (first dc()) and the second says 

  • If the vulnerability is not missing, then count AssetNames, otherwise count NULL (this counts as 0)

 

View solution in original post

0 Karma

bowesmana
SplunkTrust
SplunkTrust

That command is not a valid Splunk command

What you probably want is

| stats dc(AssetNames) AS TotalExternalAssets
        dc(eval(if(vulnerability!="missing", AssetNames, null()))) AS TotalExposedAssets

I assume the AssetNames field is the same field (not Asset_Names in the second case)

This takes the count of unique assets (first dc()) and the second says 

  • If the vulnerability is not missing, then count AssetNames, otherwise count NULL (this counts as 0)

 

0 Karma
Get Updates on the Splunk Community!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...