Operations 7 min read

Mastering Prometheus rate, irate, and increase: When and How to Use Each

This article explains how Prometheus’s rate, irate, and increase functions calculate counter growth rates, handle counter resets, and differ in smoothing and responsiveness, guiding you to choose the appropriate function for monitoring request rates, CPU usage, and other metrics.

Java One
Java One
Java One
Mastering Prometheus rate, irate, and increase: When and How to Use Each

Prometheus provides three functions— rate, irate, and increase —to compute the growth rate of counter metrics over a specified time window, which is more useful than raw counter values that only ever increase.

Function Basics

rate

: Calculates the per‑second increase across the entire window by using the first and last samples. irate: Computes the instantaneous per‑second rate using only the last two samples, giving a faster‑reacting result. increase: Returns the total increase over the window (similar to rate but without dividing by time).

All three functions require at least two samples within the window; otherwise the result is omitted. Ensure the window is large enough to contain two data points.

Handling Counter Resets

When a counter resets (drops to a lower value), Prometheus scans the window for such drops, treats them as resets, and adds the last value before the reset to subsequent samples to compensate. This correction still loses the increment that occurred just before the reset, so the rate during the reset period may be slightly low, but the impact is minor because resets are infrequent compared to scrape intervals.

rate Calculation

rate

uses the slope between the first and last samples in the window and returns the per‑second increase.

increase Calculation and Compensation

increase

returns the maximum delta observed in the window. If the time between the first and last samples is shorter than the window (e.g., less than 5 minutes), the raw delta underestimates the true increase. To compensate, Prometheus extends the line between the first and last points outward to the window edges, then uses the extrapolated delta as the result.

When the extrapolation would cross the time axis and produce negative values, increase stops at the axis intersection, avoiding negative counters.

irate Characteristics

irate

behaves like rate but always uses only the last two samples, ignoring earlier data. This makes its output more jittery and better at showing immediate changes, while still applying the same reset compensation as the other functions.

In alerting scenarios, rate is usually preferred because its smoothing aligns with the tolerance needed for alerts, whereas irate is more suited for real‑time dashboards.

Practical Recommendation

For most monitoring needs, use rate as the default. Switch to irate or increase only in specific cases where you need instant reaction or total increase values, respectively.

MonitoringMetricsPrometheusincreaseiraterate
Java One
Written by

Java One

Sharing common backend development knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.