Reference

MetricsQL rollups

Use VictoriaMetrics-specific sample statistics and rollup variants.

These helpers require mode="metricsql". They operate within a lookbehind window; the range_* transforms on the transforms page operate across the full query interval instead.

from metricraft import QueryBuilder as Q

query = Q.from_metric("queue_depth").count_gt_over_time(20, window="5m")
print(query.build(mode="metricsql"))

Here value=20 is a numeric threshold and window="5m" is a duration. In contrast, count_values_over_time(value="observed", ...) uses its value parameter as an output label name. The parameter table records these differences explicitly.

Methods and parameters

QueryBuilder

aggr_over_time()Compute several supported rollups over the same MetricsQL lookbehind window.MetricsQL only
vm only
QueryBuilder.aggr_over_time(*functions: StringInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
*functionsstr, ...VariadicOne or more rollup names accepted by aggr_over_time, such as 'min_over_time' and 'max_over_time'. Each name is checked against the Rust allowlist.
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.

ascent_over_time()Sum only positive changes between samples in the lookbehind window.MetricsQL only
vm only
QueryBuilder.ascent_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.

changes_prometheus()Use the MetricsQL changes_prometheus rollup to request Prometheus-compatible changes window behavior.MetricsQL only
vm only
QueryBuilder.changes_prometheus(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.

count_eq_over_time()Return the count of window samples whose values are equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.count_eq_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

count_gt_over_time()Return the count of window samples whose values are greater than the supplied threshold.MetricsQL only
vm only
QueryBuilder.count_gt_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

Example

from metricraft import QueryBuilder as Q

Q.from_metric("queue_depth").count_gt_over_time(20, window="5m").build(mode="metricsql")
count_le_over_time()Return the count of window samples whose values are less than or equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.count_le_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

count_ne_over_time()Return the count of window samples whose values are not equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.count_ne_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

count_values_over_time()Count occurrences of each distinct sample value in a window, adding the value to a named output label.MetricsQL only
vm only
QueryBuilder.count_values_over_time(value: StringInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valuestrRequiredNonempty output label name that stores the counted sample value; this parameter is a label, not a numeric threshold.
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.

Example

from metricraft import QueryBuilder as Q

Q.from_metric("queue_depth").count_values_over_time("observed", window="5m").build(mode="metricsql")
decreases_over_time()Count decreases between consecutive samples in the lookbehind window.MetricsQL only
vm only
QueryBuilder.decreases_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.

default_rollup()Return the last raw sample using VictoriaMetrics' default lookbehind selection.MetricsQL only
vm only
QueryBuilder.default_rollup(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.

delta_prometheus()Use the MetricsQL delta_prometheus rollup to request Prometheus-compatible delta window behavior.MetricsQL only
vm only
QueryBuilder.delta_prometheus(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.

deriv_fast()Estimate a slope from the first and last samples instead of fitting all samples.MetricsQL only
vm only
QueryBuilder.deriv_fast(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.

descent_over_time()Sum the magnitudes of negative changes between samples in the lookbehind window.MetricsQL only
vm only
QueryBuilder.descent_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.

distinct_over_time()Compute the number of distinct values of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.distinct_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.

duration_over_time()Estimate the duration represented by samples, treating gaps above the supplied maximum interval as breaks.MetricsQL only
vm only
QueryBuilder.duration_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredMaximum allowed gap between samples, in seconds; use a positive scalar.
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.

geomean_over_time()Compute the geometric mean of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.geomean_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.

histogram_over_time()Build a MetricsQL histogram from values within each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.histogram_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.

hoeffding_bound_lower()Estimate a lower Hoeffding confidence bound for the window's mean.MetricsQL only
vm only
QueryBuilder.hoeffding_bound_lower(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredConfidence probability in [0, 1]. Backend handles out-of-range/computed inputs.
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.

hoeffding_bound_upper()Estimate a upper Hoeffding confidence bound for the window's mean.MetricsQL only
vm only
QueryBuilder.hoeffding_bound_upper(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredConfidence probability in [0, 1]. Backend handles out-of-range/computed inputs.
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.

ideriv()Estimate the slope between the two most recent samples.MetricsQL only
vm only
QueryBuilder.ideriv(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.

increase_prometheus()Use the MetricsQL increase_prometheus rollup to request Prometheus-compatible increase window behavior.MetricsQL only
vm only
QueryBuilder.increase_prometheus(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.

increase_pure()Compute counter increase with MetricsQL's pure-counter treatment of initial samples.MetricsQL only
vm only
QueryBuilder.increase_pure(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.

increases_over_time()Count increases between consecutive samples in the lookbehind window.MetricsQL only
vm only
QueryBuilder.increases_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.

integrate()Estimate the integral of sample values over time, in value-seconds.MetricsQL only
vm only
QueryBuilder.integrate(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.

lag()Return seconds since the latest sample in the lookbehind window.MetricsQL only
vm only
QueryBuilder.lag(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.

lifetime()Return seconds between the first and last samples in the lookbehind window.MetricsQL only
vm only
QueryBuilder.lifetime(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.

outlier_iqr_over_time()Detect whether the latest value is an outlier relative to the window's interquartile range.MetricsQL only
vm only
QueryBuilder.outlier_iqr_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.

quantiles_over_time()Compute multiple quantiles independently for each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.quantiles_over_time(label: StringInput, *quantiles: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
labelstrRequiredNonempty label name without control characters. The builder quotes names when required by the dialect.
*quantilesint | float | QueryBuilder, ...VariadicOne or more requested quantiles, normally each in [0, 1]. PromQL histogram_quantiles accepts at most 10 quantiles; MetricsQL supports its own variadic form.
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.

range_over_time()Return the maximum sample minus the minimum sample within the lookbehind window.MetricsQL only
vm only
QueryBuilder.range_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.

rate_prometheus()Use the MetricsQL rate_prometheus rollup to request Prometheus-compatible rate window behavior.MetricsQL only
vm only
QueryBuilder.rate_prometheus(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.

rollup_candlestick()Produce open, high, low and close values over a MetricsQL lookbehind window, or select one component.MetricsQL only
vm only
QueryBuilder.rollup_candlestick(window: Optional[Window]=None, *, result: Optional[StringInput]=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 'open', 'high', 'low' or 'close'; None returns all four.

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

rollup_delta()Produce minimum, maximum and average statistics of successive sample differences over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup_delta(window: Optional[Window]=None, *, result: Optional[StringInput]=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.

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

rollup_deriv()Produce minimum, maximum and average statistics of successive per-second slopes over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup_deriv(window: Optional[Window]=None, *, result: Optional[StringInput]=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.

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

rollup_increase()Produce minimum, maximum and average statistics of counter increases over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup_increase(window: Optional[Window]=None, *, result: Optional[StringInput]=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.

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

rollup_scrape_interval()Produce minimum, maximum and average statistics of sample intervals over a MetricsQL lookbehind window, or select one statistic.MetricsQL only
vm only
QueryBuilder.rollup_scrape_interval(window: Optional[Window]=None, *, result: Optional[StringInput]=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.

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

scrape_interval()Estimate the interval in seconds between raw samples.MetricsQL only
vm only
QueryBuilder.scrape_interval(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.

share_eq_over_time()Return the fraction of window samples whose values are equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.share_eq_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

share_gt_over_time()Return the fraction of window samples whose values are greater than the supplied threshold.MetricsQL only
vm only
QueryBuilder.share_gt_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

share_le_over_time()Return the fraction of window samples whose values are less than or equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.share_le_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

stale_samples_over_time()Count stale markers in a MetricsQL lookbehind window.MetricsQL only
vm only
QueryBuilder.stale_samples_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.

sum2_over_time()Compute the sum of squared values of samples in each series' lookbehind window.MetricsQL only
vm only
QueryBuilder.sum2_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.

sum_eq_over_time()Return the sum of window samples whose values are equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.sum_eq_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

sum_gt_over_time()Return the sum of window samples whose values are greater than the supplied threshold.MetricsQL only
vm only
QueryBuilder.sum_gt_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

sum_le_over_time()Return the sum of window samples whose values are less than or equal to the supplied threshold.MetricsQL only
vm only
QueryBuilder.sum_le_over_time(value: ScalarInput, window: Optional[Window]=None) -> QueryBuilder
Parameters
Parameter / typeMeaning and accepted values
valueint | float | QueryBuilderRequiredThreshold compared with each raw sample in the window. Any numeric scalar is accepted; bool is rejected. Samples satisfying the named comparison contribute to the result.
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.

tfirst_over_time()Return the Unix timestamp of the first value in the lookbehind window.MetricsQL only
vm only
QueryBuilder.tfirst_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.

timestamp_with_name()Return the latest sample timestamp while retaining the metric name.MetricsQL only
vm only
QueryBuilder.timestamp_with_name(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.

tlast_change_over_time()Return the timestamp of the last sample value change in the window.MetricsQL only
vm only
QueryBuilder.tlast_change_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.

tlast_over_time()Return the Unix timestamp of the last value in the lookbehind window.MetricsQL only
vm only
QueryBuilder.tlast_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.

tmax_over_time()Return the Unix timestamp of the last occurrence of the maximum in the lookbehind window.MetricsQL only
vm only
QueryBuilder.tmax_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.

tmin_over_time()Return the Unix timestamp of the last occurrence of the minimum in the lookbehind window.MetricsQL only
vm only
QueryBuilder.tmin_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.

Explore the docs

Find your next step

Search guides, examples and the Python API.