---
source: https://iinventedlight.com/library/notes/prometheus-rate-increase.md
title: "PromQL rate(), irate() and increase() turn counters into per-second rates or totals"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Prometheus docs); Apache-2.0 (prometheus/prometheus (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Prometheus docs, Query functions; prometheus/prometheus (GitHub), Query functions (source page). Apache-2.0 (https://raw.githubusercontent.com/prometheus/prometheus/main/LICENSE). Copyright The Prometheus Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Prometheus rate and increase"
tags: [prometheus, promql, rate, irate, increase, counters]
client: Librarian
sources:
  - id: S1
    title: "Query functions"
    publisher: Prometheus docs
    url: https://prometheus.io/docs/prometheus/latest/querying/functions/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "Query functions (source page)"
    publisher: prometheus/prometheus (GitHub)
    url: https://github.com/prometheus/prometheus/blob/main/docs/querying/functions.md
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# PromQL rate(), irate() and increase() turn counters into per-second rates or totals
**Answer:** Use `rate(counter[5m])` for the per-second average rate of increase over a range, `irate()` for the per-second instant rate based on the last two data points, and `increase()` for the total increase in the range. Each of them should only be used with counters.

## Examples

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

## How they behave

- `rate(v range-vector)` computes the per-second average rate of increase for each series in the range vector. Counter resets due to target restarts and other breaks in monotonicity are adjusted for automatically.
- `rate` also extrapolates to the ends of the time range, which allows for missed scrapes or imperfect alignment of scrape cycles with the range.
- `irate(v range-vector)` gives the per-second instant rate of increase, based on the last two data points, looking back up to the range for the two most recent samples.
- `increase(v range-vector)` is syntactic sugar for `rate(v)` multiplied by the number of seconds under the time range window.

## Gauges are different

`idelta` should only be used with gauges. Elements that mix float samples and histogram samples in the range are omitted from the result and flagged by a warn-level annotation.

## See also

- [prometheus-promql-selectors](https://iinventedlight.com/library/notes/prometheus-promql-selectors/)
- [kubernetes-horizontal-pod-autoscaling](https://iinventedlight.com/library/notes/kubernetes-horizontal-pod-autoscaling/)

## Claims

- id: C1
  claim: rate calculates the per-second average rate of increase.
  source: S2
  evidence: "calculates the per-second average rate of increase of the time series in the range vector"

- id: C2
  claim: irate is based on the last two data points.
  source: S2
  evidence: "This is based on the last two data points."

- id: C3
  claim: increase is syntactic sugar for rate times the window seconds.
  source: S2
  evidence: "It is syntactic sugar for `rate(v)` multiplied by the number of seconds"

- id: C4
  claim: idelta should only be used with gauges.
  source: S1
  evidence: "should only be used with gauges"

## Sources

- [S1] Query functions. Prometheus docs. https://prometheus.io/docs/prometheus/latest/querying/functions/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] Query functions (source page). prometheus/prometheus (GitHub). https://github.com/prometheus/prometheus/blob/main/docs/querying/functions.md . License: Apache-2.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Prometheus docs, Query functions; prometheus/prometheus (GitHub), Query functions (source page). Apache-2.0 (https://raw.githubusercontent.com/prometheus/prometheus/main/LICENSE). Copyright The Prometheus Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
