rate
rate(value: numeric or duration) -> value
Computes an average per-second rate from a numeric or duration series over each aggregation frame. It is implemented as paired aggregates (delta value and, in window mode, delta time) with a preparatory lag step, so the input table must declare a valid-from timestamp column in metadata; without it compilation fails. The surrounding aggregate must use time-bin aggregation: pure grouping verbs such as timestats are rejected with a message to use align or timechart instead. The aggregate frame must be non-zero (frame(back: ...), frame(ahead: ...), or equivalent from window); a zero-width frame is an error. By default values are treated like a monotonic counter where a decrease implies a reset to zero before continuing, so the per-interval contribution is never negative; when the expression references m and metadata marks the metric as delta, the implementation switches to summing raw deltas per frame and dividing by frame duration, and heuristics may warn if a delta-typed metric is used without metadata. Non-delta modes coerce the output to float64 even for integer inputs because division is involved. When alignment uses an auto-computed bin width, the denominator can be recomputed from the query window so rates stay consistent with the effective bucket size.
Domain
This is an aggregate function (aggregates rows over a group in aggregate verbs).
This is a window function (calculates over a group of multiple input rows using windowing).
Categories
Examples
align 1m, frame(back: 2m), o: rate(m("network_bytes_total"))
Computes per-second bytes for a cumulative counter metric using a non-zero frame and time-binned alignment.
align 30s, frame(back: 30s), o: rate(counter_value)
Shows rate applied to a numeric counter column with explicit thirty-second framing suitable for dense dashboards.
Updated 18 days ago