What is the difference between the rate() and increase() functions in PromQL?
sobes.tech AI
Answer from AI
In PromQL, the functions rate() and increase() work with counters but serve different purposes:
-
rate()calculates the average rate of change of a counter over a specified time interval. It returns the value in units of change per second. This is useful when you need to know the speed of events, such as requests per second. -
increase()calculates the total increase in the counter's value over a specified time interval. It returns the absolute number of increases over the period.
Example:
rate(http_requests_total[5m])
Returns the average number of requests per second over the last 5 minutes.
increase(http_requests_total[5m])
Returns the total number of requests over the last 5 minutes.
Thus, rate() is convenient for monitoring speed, while increase() is used for counting the total number of events over a period.