Splunk Search

How do I edit my search to get the distinct count for fields generated with eval?

raindrop18
Communicator

I have this search and I want only the unique count. I'm getting the unique count for the id field, but not for Permit and Deny How can I fix my search to get the unique count for Permit and Deny?

|  stats dc(id), count(eval(_raw LIKE "%Permit%")) as "Permit" , count(eval(_raw LIKE "%Deny%")) as "Deny" by username

thanks,

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To count only unique Permit and Deny strings, use dc instead of count.

| stats dc(id), dc(eval(_raw LIKE "%Permit%")) as "Permit" , dc(eval(_raw LIKE "%Deny%")) as "Deny" by username
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

To count only unique Permit and Deny strings, use dc instead of count.

| stats dc(id), dc(eval(_raw LIKE "%Permit%")) as "Permit" , dc(eval(_raw LIKE "%Deny%")) as "Deny" by username
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...