Commit 6412fad0 authored by Brian Brazil's avatar Brian Brazil Committed by Julius Volz

Document the instant rate.

Hamming up the "angry" meaning just a tad.
parent 760ebcf3
...@@ -159,6 +159,31 @@ increase(http_requests_total{job="api-server"}[5m]) ...@@ -159,6 +159,31 @@ increase(http_requests_total{job="api-server"}[5m])
human readability. Use `rate` in recording rules so that increases are tracked human readability. Use `rate` in recording rules so that increases are tracked
consistently on a per-second basis. consistently on a per-second basis.
## `irate()`
`irate(v range-vector)` calculates the per-second instant rate of increase of
the time series in the range vector. This is based on the last two data points.
Breaks in monotonicity (such as counter resets due to target restarts) are
automatically adjusted for.
The following example expression returns the per-second rate of HTTP requests
looking up to 5 minutes back for the two most recent data points, per time
series in the range vector:
```
irate(http_requests_total{job="api-server"}[5m])
```
`irate` should only be used when graphing volatile, fast-moving counters.
Use `rate` for alerts and slow-moving counters, as brief changes
in the rate can reset the `FOR` clause and graphs consisting entirely of rare
spikes are hard to read.
Note that when combining `irate()` with an aggregation operator (e.g. `sum()`)
or a function aggregating over time (any function ending in `_over_time`),
always take a `irate()` first, then aggregate. Otherwise `irate()` cannot detect
counter resets when your target restarts.
## `label_replace()` ## `label_replace()`
For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string, For each timeseries in `v`, `label_replace(v instant-vector, dst_label string, replacement string,
...@@ -216,7 +241,8 @@ over the last 5 minutes, per time series in the range vector: ...@@ -216,7 +241,8 @@ over the last 5 minutes, per time series in the range vector:
rate(http_requests_total{job="api-server"}[5m]) rate(http_requests_total{job="api-server"}[5m])
``` ```
`rate` should only be used with counters. `rate` should only be used with counters. It is best suited for alerting,
and for graphing of slow-moving counters.
Note that when combining `rate()` with an aggregation operator (e.g. `sum()`) Note that when combining `rate()` with an aggregation operator (e.g. `sum()`)
or a function aggregating over time (any function ending in `_over_time`), or a function aggregating over time (any function ending in `_over_time`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment