How to get total requests in a given period of time?
Answer
To get the total requests in a given period of time using Prometheus, you can use the sum function along with the rate function. Here is an example query that will give you the total number of requests in the last hour:
sum(rate(http_requests_total[1h]))
In this query, http_requests_total is the name of the metric that tracks the total number of HTTP requests, and the rate function calculates the per-second rate of requests over the last hour. The sum function then adds up all of the requests to give you the total number of requests in the last hour.
You can adjust the time range by changing the duration in the rate function. For example, if you wanted to get the total number of requests in the last day, you could change the function to rate(http_requests_total[1d]).