Splunk Search

List of top URLs with hourly count > 50

Shashank_87
Explorer

Hi, I have a ask where I need to find out top 100 URL's who have hourly hits more than 50 on the server means if a particular URL is requested more than 50 times in an hour then I need to list it.
And I need to list these kind of top 100 URL's which are most visited.
Any help is appreciated. Below is the query I have but it is not giving what i want -

index=temp_index source="/app/request.log" host="server-1b*" GET
| rex field=_raw "GET (?[^\s]+)"
| bucket span=1h _time
| stats count as hour_count by _time requested_content

0 Karma
1 Solution

manjunathmeti
Champion

Hi @Shashank_87,

If you are extracting URL from _raw and counting it then try this:

index=temp_index source="/app/request.log" host="server-1b*" GET
| rex field=_raw "GET (?<URL>[^\s]+)"
| bucket span=1h _time
| stats count as hour_count by _time URL
| where hour_count > 50
| top 100 URL

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this

index=temp_index source="/app/request.log" host="server-1b*" GET
| rex field=_raw "GET (?<requested_content>[^\s]+)"
| bucket span=1h _time
| stats count as hour_count by _time requested_content
| where hour_content>50 
| sort 100 -hour_content

OR

index=temp_index source="/app/request.log" host="server-1b*" GET
| rex field=_raw "GET (?<requested_content>[^\s]+)"
| bucket span=1h _time
| stats count as hour_count by _time requested_content
| where hour_content>50 | stats max(hour_content) as hour_content by requested_content
| sort 100 -hour_content

Shashank_87
Explorer

@somesoni2 Hi, this is also one of the solution and works in my situation but it gives multiple rows with the same URL which is fine because duplicates can be removed.
Thanks very much for the response.

0 Karma

manjunathmeti
Champion

Hi @Shashank_87,

If you are extracting URL from _raw and counting it then try this:

index=temp_index source="/app/request.log" host="server-1b*" GET
| rex field=_raw "GET (?<URL>[^\s]+)"
| bucket span=1h _time
| stats count as hour_count by _time URL
| where hour_count > 50
| top 100 URL
0 Karma

Shashank_87
Explorer

@manjunathmeti Hi Manju, this has worked perfectly. Thanks very much.

0 Karma

manjunathmeti
Champion

You're welcome!

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...