The rate() function in Prometheus calculates the average per-second increase of a counter over a specified time range.
It is used to determine how fast a value, such as a counter, is increasing every second, averaged over the designated time window.
rate() works exclusively on counters, providing an instant vector with one data point per series for the current evaluation time. It is beneficial for alerting and visualizations, especially for slow-moving metrics.
When using rate(), always apply it before aggregators like sum() or avg(), limit its use to counters and histograms, and consider using it for alerting thresholds.