2
votes

I'm really stumped here with trying to figure out the rate() function for Prometheus. Looking at the documentation for rate(), I'm failing to understand their example:

rate(http_requests_total{job="api-server"}[5m])

And the description:

The following example expression returns the per-second rate of HTTP requests as measured over the last 5 minutes, per time series in the range vector

That 5 minutes is stumping me. You're getting the per-second rate of requests (even though a scrape would be, for instance, every 15s) but where does the "over the last 5 minutes" come into play? I'm looking at a graph that spans 30 minutes, and "over the last 5 minutes" means what with that query/equation?

Thanks in advance. Hoping somebody can explain this in different terms!

1

1 Answers

4
votes

For every vertical slice of the graph, the rate will be calculated over the 5 minutes before it.