Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does prometheus rate works with grafana?

The rate function in grafana for example:- rate(http_requests_total{job="api-server"}[5m]) returns the per-second rate of HTTP requests as measured over the last 5 minutes. How does this work with the time range that we set in grafana dashboard like 2h,4h, 24h etc.

like image 246
Rohit Singh Avatar asked Jan 24 '26 15:01

Rohit Singh


1 Answers

There are no interrelations between these two settings. For example, if rate(http_requests_total{job="api-server"}[5m]) is your PromQL query, it yields a single value when you execute it at a specific point in time. If you have a Grafana dashboard with a 2h time range, then Grafana just repeatedly executes this query at a series of point in times during the past 2 hours, and displays you the result of each query as e.g. a graph.

For example, if the time range of your Grafana dashboard is 2h and the interval is set to 1 minute, then Grafana executes your query 120 times during the time span ranging the past 2 hours. The results of all these queries form a graph and that's what you see in your Grafana dashboard.

The interval with which Grafana executes the query is determined by the Max data points and Min interval settings in the Query options of your Grafana dashboard:

enter image description here

See the explanations about these settings in the Grafana documentation.

Note: Grafana uses the query_range endpoint of the Prometheus API to repeatedly execute the query over the given time range.

like image 151
weibeld Avatar answered Jan 27 '26 04:01

weibeld



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!