Grafana Rate Per Second Calculator
Calculate metric frequency and understand rate() functions
Resulting Metrics
How Grafana Calculates Rate per Second
In Grafana, specifically when using data sources like Prometheus, the rate() function is used to calculate the per-second average rate of increase of a time series in a range vector. This is essential for monitoring requests per second, CPU usage, or network throughput.
The Mathematical Formula
Rate = (Value at End of Range – Value at Start of Range) / Time Range in Seconds
While the basic math is a simple division, Prometheus performs "extrapolation" to handle instances where the first or last samples don't align perfectly with the range boundaries. It also handles counter resets (when a service restarts and the counter goes back to zero).
Rate vs. Irate: Which one to use?
- rate([range]): Calculates the average per-second rate over the entire specified time window (e.g., 5 minutes). Use this for alerting and slow-moving trends.
- irate([range]): The "instant rate." It only looks at the last two data points in the range. Use this for high-resolution graphs to see volatile spikes.
Example Calculation
If your http_requests_total counter was at 10,000 at 12:00 PM and rose to 13,000 by 12:05 PM:
- Delta: 13,000 – 10,000 = 3,000 requests.
- Time: 5 minutes = 300 seconds.
- Calculation: 3,000 / 300 = 10 requests per second.