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

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

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

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

You're welcome!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...