Splunk Search

How to show the top command with distinct value?

igschloessl
Explorer

I've got proxy logs and I want to show the top 5 urls and for that the count of distinct users who tried to access it.
I tried the following search command

index=proxy
| eval dc_user=[search* stats dc(user) by url| return $dc_user]
| top dest_host limit=5
| table dest_host dc_user

How can I get this work?
I also wanted to add the count of the url and the percentage.

Thank you in advance.

Tags (1)

cpmoone
Engager

Does this do what you need?

index=proxy
| eventstats dc(user) as unique_users by url
| top url 
| sort 5 - count
| table url, unique_users, count, percent

somesoni2
Revered Legend

Give this a try

index=proxy 
| stats dc(user) as UniqUsers count by dest_host
| sort 5 -count
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 ...