Getting Data In

How to get the number of "unique" request with splunk

ChrisJack
New Member

We are currently looking for a way to find the number of "unique" request for a given event type with splunk. Like the number of user that hit a 404, but i don't care if a user hit it twice or 10 times, I just want the number of user that had that error. Is there anyway to do that with splunk ?

Tags (3)
0 Karma
1 Solution

Ayn
Legend

Use the stats operator dc (an alias for distinct_count). Let's say you have the fields httpResponseCode and user. To get a count of how many users got an httpResponseCode of 404, regardless of how many times each user got it, you'd do:

httpResponseCode=404 | stats dc(user)

More information on the dc stats function, along with others, is available here: http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions

View solution in original post

Ayn
Legend

Use the stats operator dc (an alias for distinct_count). Let's say you have the fields httpResponseCode and user. To get a count of how many users got an httpResponseCode of 404, regardless of how many times each user got it, you'd do:

httpResponseCode=404 | stats dc(user)

More information on the dc stats function, along with others, is available here: http://docs.splunk.com/Documentation/Splunk/4.2.2/SearchReference/CommonStatsFunctions

Ayn
Legend

Yes, that should work fine.

0 Karma

ChrisJack
New Member

Our user is extracted from the request using a extract field.

Example : localhost_access_log : EXTRACT-myUser =
(?i)/users/(?P[^/]+)

Will I be able to go : httpResponseCode=404 | stats dc(myUser)

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

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