Splunk Search

Find average count per minute by a specific field over the whole time period

flls
New Member

Hi,

I have a web service's http access log and I want to find out the average request per minute for each url_path over the WHOLE period. A timechart of per minute average is not what I need.

I tried the following search query, but because during some minutes some url_path may not have events at all, and this search does not give the correct statistics.

sourcetype=accesslog | bucket _time span=1m | stats count by _time url_path | stats avg(count) as avg_per_min by url_path

This should be a very simple use case, but still cannot find a solution to that, could anyone help ?

Tags (1)
0 Karma

woodcock
Esteemed Legend

As @somesoni2 said, you probably have gaps where there are no events and these gaps will cause your math to be bad. You could do this work yourself with the makecontinuous command but one of the (many) nice things that timechart does is fill in 0 values for empty slots so try this:

sourcetype=accesslog 
| timechart limit=0 span=1m count BY url_path 
| untable _time sourcetype events_per_min
| stats avg(events_per_min) AS avg_per_min BY url_path 
0 Karma

somesoni2
Revered Legend

Give this a try.

sourcetype=accesslog | stats count by url_path | addinfo | eval mins=(info_max_time-info_min_time)/60 | eval avepermin=count/mins
0 Karma

somesoni2
Revered Legend

The addinfo commands gives the current time range based on which total no of minutes are calculated.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

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