Reference

Rates & window statistics

Compute rates and summaries over each series' lookbehind window.

Give a window when starting from an instant selector, or apply a rollup to an existing range. Omitting a window on a bare selector selects MetricsQL implicit-rollup behavior and cannot build as PromQL.

from metricraft import QueryBuilder as Q

counter = Q.from_metric("requests_total")
print(counter.rate("5m").build(mode="promql"))
gauge = Q.from_metric("temperature_celsius")
print(gauge.avg_over_time("10m").build(mode="promql"))

Use rates and increases with counters, and delta/deriv with gauges. Equal function names do not imply identical Prometheus and VictoriaMetrics sample-edge behavior. window and its compatibility alias duration are mutually exclusive.

Methods and parameters

QueryBuilder

absent_over_time()Return 1 when the range input has no samples; otherwise return no series.
QueryBuilder.absent_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

avg_over_time()Compute the arithmetic mean of samples in each series' lookbehind window.
QueryBuilder.avg_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

changes()Count value changes over a lookbehind window; the two dialects differ in their use of a sample before the window.
QueryBuilder.changes(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

count_over_time()Compute the count of samples in each series' lookbehind window.
QueryBuilder.count_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

delta()Compute the change in a gauge across a lookbehind window. Window-edge extrapolation depends on the backend.
QueryBuilder.delta(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

deriv()Estimate a gauge's per-second slope using linear regression over the lookbehind window.
QueryBuilder.deriv(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

double_exponential_smoothing()Smooth gauge samples using level and trend factors. Requires Prometheus experimental-functions opt-in.PromQL only
prom onlyprom experimental
QueryBuilder.double_exponential_smoothing(window: Optional[Window]=None, *, smoothing_factor: ScalarInput=0.3, trend_factor: ScalarInput=0.3) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
smoothing_factorint | float | QueryBuilderDefault: 0.3Level smoothing factor, strictly between 0 and 1. Higher values give recent samples more weight; literal factors are checked by Rust.
trend_factorint | float | QueryBuilderDefault: 0.3Trend smoothing factor, strictly between 0 and 1. Literal factors are checked by Rust.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

first_over_time()Return the first sample in each series' lookbehind window.
QueryBuilder.first_over_time(window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

holt_winters()Apply MetricsQL double exponential smoothing with separate level and trend factors.MetricsQL only
vm only
QueryBuilder.holt_winters(duration: Optional[Window]='5m', smoothing_factor: ScalarInput=0.3, trend_factor: ScalarInput=0.3) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
durationstr | QueryBuilder | NoneDefault: '5m'Lookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.
smoothing_factorint | float | QueryBuilderDefault: 0.3Level smoothing factor, strictly between 0 and 1. Higher values give recent samples more weight; literal factors are checked by Rust.
trend_factorint | float | QueryBuilderDefault: 0.3Trend smoothing factor, strictly between 0 and 1. Literal factors are checked by Rust.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

idelta()Subtract the penultimate gauge sample from the most recent sample.
QueryBuilder.idelta(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

increase()Compute counter growth over a lookbehind window, accounting for resets. Exact window-edge behavior depends on the backend.
QueryBuilder.increase(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

irate()Compute a counter's per-second rate from its two most recent samples, adjusting for a reset.
QueryBuilder.irate(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

last_over_time()Return the last sample in each series' lookbehind window.
QueryBuilder.last_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

mad_over_time()Compute the median absolute deviation of samples in each series' lookbehind window.
prom experimental
QueryBuilder.mad_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

max_over_time()Compute the maximum of samples in each series' lookbehind window.
QueryBuilder.max_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

median_over_time()Compute the median of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.median_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

min_over_time()Compute the minimum of samples in each series' lookbehind window.
QueryBuilder.min_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

mode_over_time()Compute the most frequent value of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.mode_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

moving_average()Convenience wrapper for avg_over_time() with a default five-minute window.
QueryBuilder.moving_average(duration: Optional[Window]='5m') -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
durationstr | QueryBuilder | NoneDefault: '5m'Lookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

predict_linear()Predict a gauge value a number of seconds forward using a linear fit to the lookbehind window.
QueryBuilder.predict_linear(seconds: Optional[ScalarInput]=None, window: Optional[Window]=None, *, prediction_seconds: Optional[ScalarInput]=None, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
secondsint | float | QueryBuilder | NoneDefault: NonePrediction horizon in seconds. Positive values project forward; pass either seconds or prediction_seconds, and provide one of them.
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
prediction_secondsint | float | QueryBuilder | NoneDefault: NoneAlias of seconds; do not supply both.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

present_over_time()Return 1 for each series with at least one sample in the lookbehind window.
QueryBuilder.present_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

quantile_over_time()Compute a quantile over samples within each series' lookbehind window.
QueryBuilder.quantile_over_time(q: Optional[ScalarInput]=None, window: Optional[Window]=None, *, quantile: Optional[ScalarInput]=None, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
qint | float | QueryBuilder | NoneDefault: NoneQuantile, normally in [0, 1]. Supply either q or quantile, never both; None is valid only when the alias provides the value.
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
quantileint | float | QueryBuilder | NoneDefault: NoneAlias of q. Supply exactly one of q or quantile; normally use [0, 1].
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

rate()Compute a per-second counter increase over a lookbehind window. Prometheus extrapolates to window boundaries; MetricsQL has different rollup semantics.
QueryBuilder.rate(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

Example

from metricraft import QueryBuilder as Q

Q.from_metric("requests_total").rate("5m").build(mode="promql")
rate_over_sum()Express the sum of window samples as a per-second rate; useful for gauge measurements accumulated within each interval.MetricsQL only
vm only
QueryBuilder.rate_over_sum(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

resets()Count counter resets in the lookbehind window.
QueryBuilder.resets(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

rollup()Produce minimum, maximum and average statistics of raw values over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup(window: Optional[Window]=None, duration: Optional[Window]=None, *, result: Optional[StringInput]=None, func: Optional[StringInput]=None) -> QueryBuilder

Prefer rollup(window='5m', result='avg'). The compatibility form rollup('avg', '5m') is accepted. window/duration and result/func are mutually exclusive aliases.

Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.
resultstr | NoneDefault: NoneSelect 'min', 'max' or 'avg'; None emits all three result series.
funcstr | NoneDefault: NoneCompatibility alias of result ('min', 'max', 'avg'); do not pass both.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

rollup_rate()Produce minimum, maximum and average statistics of per-second counter changes over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup_rate(window: Optional[Window]=None, *, result: Optional[StringInput]=None, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
resultstr | NoneDefault: NoneSelect 'min', 'max' or 'avg'; None emits all three result series.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

stddev_over_time()Compute the population standard deviation of samples in each series' lookbehind window.
QueryBuilder.stddev_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

stdvar_over_time()Compute the population variance of samples in each series' lookbehind window.
QueryBuilder.stdvar_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

sum_over_time()Compute the sum of samples in each series' lookbehind window.
QueryBuilder.sum_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

ts_of_first_over_time()Return the Unix timestamp of the first value in the lookbehind window.PromQL only
prom onlyprom experimental
QueryBuilder.ts_of_first_over_time(window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

ts_of_last_over_time()Return the Unix timestamp of the last value in the lookbehind window.PromQL only
prom onlyprom experimental
QueryBuilder.ts_of_last_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

ts_of_max_over_time()Return the Unix timestamp of the last occurrence of the maximum in the lookbehind window.PromQL only
prom onlyprom experimental
QueryBuilder.ts_of_max_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

ts_of_min_over_time()Return the Unix timestamp of the last occurrence of the minimum in the lookbehind window.PromQL only
prom onlyprom experimental
QueryBuilder.ts_of_min_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

zscore_over_time()Compute the z-score of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.zscore_over_time(window: Optional[Window]=None, *, duration: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
windowstr | QueryBuilder | NoneDefault: NonePositive lookbehind duration, e.g. '5m' or '1h30m'. None preserves an existing range or uses MetricsQL implicit rollup; a bare selector without a window cannot build as PromQL. Duration expressions need the relevant dialect/feature support.
durationstr | QueryBuilder | NoneDefault: NoneLookbehind duration, e.g. '5m'. Where window is also accepted, pass one name only. None preserves the current range or requests MetricsQL implicit rollup.

Returns QueryBuilder — a new immutable expression sharing unchanged native subtrees. The receiver is unchanged; no data is queried.

Explore the docs

Find your next step

Search guides, examples and the Python API.