Basic PromQL Querying

All Topics

Computing Derivatives

Computing Derivatives

rate(), irate(), and increase() only work for counters. For gauge metrics (values that go up AND down), use different functions.

delta() — raw change over a time window. Returns the difference between the first and last value in the window:

delta(disk_usage_bytes{job="demo"}[15m])

This tells you: "how much did disk usage change in the last 15 minutes?"

Note: delta() only considers the first and last data points — it ignores intermediate trends.

deriv() — per-second derivative using linear regression. Uses all data points in the window to calculate a more accurate rate of change:

deriv(disk_usage_bytes{job="demo"}[15m])

This is more robust than delta() because it considers the overall trend, not just two endpoints.

predict_linear() — forecast future values. Extrapolates the linear trend to predict what a gauge will be at a future time:

predict_linear(disk_usage_bytes{job="demo"}[15m], 3600)

This predicts disk usage one hour from now based on the last 15 minutes of data. Useful for alerts like "disk will be full in 4 hours."