Trend and prediction functions

Trend functions read gauges — values that go up and down — and answer how much a value moved, which way it is heading, and where it will be.

changes

Counts how many times each series changed value within the range window. Good for spotting flapping states and config churn.

Syntax

changes(<gauge>[<range>])
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

Count how often the query-service goroutine gauge changed value in ten minutes.

max(changes(go_goroutines{app_kubernetes_io_name="query-service"}[10m]))
Expected output
Value

19

A perfectly flat series returns 0; every scrape-to-scrape difference counts once.

delta

Computes the difference between the first and last value of each series in the range window, extrapolated to the window ends. The gauge counterpart of increase: how much did this value move.

Syntax

delta(<gauge>[<range>])
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

Measure how much the query-service goroutine count changed over the last 30 minutes.

sum(delta(go_goroutines{app_kubernetes_io_name="query-service"}[30m]))
Expected output
Value

34.06

For counters use increase, which handles resets.

deriv

Computes the per-second derivative of each series using simple linear regression over the range window — a smoothed answer to "which way is this gauge heading, and how fast".

Syntax

deriv(<gauge>[<range>])
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

Estimate the current growth rate of query-service goroutines.

sum(deriv(go_goroutines{app_kubernetes_io_name="query-service"}[30m]))
Expected output
Value

0.02797

Regression smooths noise better than delta / window, at slightly more cost.

double_exponential_smoothing

Smooths each series using double exponential (Holt-Winters) smoothing: sf weighs recent samples, tf weighs recent trend. Produces a stable signal from a noisy gauge.

Syntax

double_exponential_smoothing(<gauge>[<range>], <sf>, <tf>)
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

Smooth the query-service goroutine gauge with balanced smoothing and trend factors.

sum(double_exponential_smoothing(go_goroutines{app_kubernetes_io_name="query-service"}[30m], 0.5, 0.5))
Expected output
Value

64,783.09

Both factors are between 0 and 1: lower sf smooths harder, higher tf follows trend changes faster.

This function was named holt_winters in Prometheus 2.x; Kloudfuse uses the current name.

idelta

Computes the difference between the last two samples in the range window — the most recent movement of a gauge.

Syntax

idelta(<gauge>[<range>])
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

See the latest sample-to-sample change in query-service goroutines.

sum(idelta(go_goroutines{app_kubernetes_io_name="query-service"}[10m]))
Expected output
Value

35

Like irate, idelta is volatile by design; use delta for smoother trends.

predict_linear

Predicts the value of each series t seconds from now by linear regression over the range window. The classic capacity alert: fire when disk will be full in four hours, not when it is full.

Syntax

predict_linear(<gauge>[<range>], <seconds-ahead>)
none

Parameters

Parameter Required Description

<range>

Required

The trailing window to compute over.

Example

Project the query-service goroutine count one hour ahead based on the last 30 minutes.

sum(predict_linear(go_goroutines{app_kubernetes_io_name="query-service"}[30m], 3600))
Expected output
Value

64,614.52

Linear extrapolation only — for trends that curve, use the forecasting algorithms: AI and ML Capabilities.