Splunk Search

Search for unique count of users

bnitesh
Explorer

Hi,

I have a Splunk query which lets me view the frequency of visits to pages in my app.

sourcetype="iis" source="*Prod*" cs_uri_filepath="Web/View*" cs_username!="-" | rex Field=cs_uri_filepath "web/view/(?<TabOrFormName>[_A-Za-z]*)" | stats count by TabOrFormName

Now I also want to get numbers for all unique users visiting these urls. Any ideas on how I can do this?

Tags (1)
1 Solution

Ayn
Legend
... | stats dc(cs_username) by TabOrFormName

View solution in original post

RicoSuave
Builder

Try this:

sourcetype="iis" source="*Prod*" cs_uri_filepath="Web/View*" cs_username!="-" | rex Field=cs_uri_filepath "web/view/(?<TabOrFormName>[_A-Za-z]*)" | stats count as visits by TabOrFormName | append [ search sourcetype="iis" source="*Prod*" cs_uri_filepath="Web/View*" cs_username!="-" | rex Field=cs_uri_filepath "web/view/(?<TabOrFormName>[_A-Za-z]*)" | stats dc(cs_username) as DistinctCountofUsers by TabOrFormName] | table TabOrFormName visits DistinctCountofUsers
0 Karma

Ayn
Legend
... | stats dc(cs_username) by TabOrFormName

bnitesh
Explorer

Works like a charm!

0 Karma

bnitesh
Explorer

cs_username stores the usernames. So I was thinking of using count over cs_username for each row of the final search or something like that.

0 Karma

Ayn
Legend

Well how would you distinguish unique users based on your log contents?

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 ...