Queries icon
OutputValues icon
Log icon
If icon
UploadFiles icon
Fail icon
SlackIncomingWebhook icon
Schedule icon

Forecast how many days each volume has before it is full

Forecast when each disk or volume will be full with Kestra and DuckDB regression. Flags critical, warning and unpredictable growth.

Categories
DataInfrastructure

A disk alert at 90% fires when the volume is already in trouble, and it fires the same way for a volume that grows 0.1% a day and one that grows 5% a day. This flow answers the question operators actually need answered: how many days does each volume have left? It fits a linear trend per volume on the recent samples and projects the date it reaches full_threshold_pct:

  • FULL: already at or above the threshold.
  • CRITICAL: full within critical_days.
  • WARNING: full within warning_days.
  • UNPREDICTABLE: growing, but the trend fit is weaker than min_r2, so a date would be fiction.
  • OK: everything else, including shrinking or flat volumes.

Only FULL and CRITICAL page.

It runs with no setup and no network. DuckDB generates 30 days of hourly samples for 8 volumes with realistic shapes: steady growth, flat, noisy, a sawtooth from a cleanup job, and growth that accelerates in the last days.

How it works

  1. forecast (io.kestra.plugin.jdbc.duckdb.Queries) keeps the last fit_window_days, fits regr_slope, regr_intercept and regr_r2 per volume, projects days_until_full and full_on, classifies the volume and writes forecast.csv.
  2. summary (io.kestra.plugin.core.output.OutputValues) builds the urgent, warning and unpredictable lists. log_forecast prints one line per volume.
  3. page_if_urgent (io.kestra.plugin.core.flow.If):
    • Urgent volumes: publish_forecast (io.kestra.plugin.core.namespace.UploadFiles) writes capacity/storage-forecast.csv, then page (io.kestra.plugin.core.execution.Fail) fails the run, so the errors block pages on-call through Slack when notify_slack is true.
    • Otherwise: log the warnings.
  4. every_6_hours (io.kestra.plugin.core.trigger.Schedule).

Quick start

With the defaults (full at 90%, 14-day fit):

Status Volume Now Growth R² Full on
CRITICAL pg-primary-data 86.8% 0.95%/day 1.0 in 3.8 days
WARNING kafka-broker-1-logs 70.3% 1.7%/day 0.99 in 11.3 days
UNPREDICTABLE object-staging 59% 0.45%/day 0.05 no date
OK wal-archive 59.3% 0.81%/day 0.74 in 44.7 days

Run it with fit_window_days: 3. wal-archive jumps to WARNING, full in 10.6 days, because its growth accelerated in the last few days and the 14-day fit averaged it away. Pick the window by how fast your workloads change.

Inputs

  • full_threshold_pct (INT, default 90), critical_days (INT, default 7), warning_days (INT, default 30).
  • min_r2 (FLOAT, default 0.7), fit_window_days (INT, default 14).

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook, used by the errors block when notify_slack is true to page when a volume is full or critical or when the forecast fails. In Kestra OSS, provide it as the base64-encoded environment variable SECRET_SLACK_WEBHOOK_URL.

Expected outputs

  • outputs.forecast.outputs: one row per volume with current_pct, pct_per_day, r2, days_until_full, status, full_on.
  • Namespace file capacity/storage-forecast.csv when something is urgent.

Using it with your metrics

  • Export usage from Prometheus (node_filesystem_avail_bytes), CloudWatch or your database's size views to CSV or Parquet, then replace the generator with read_csv or read_parquet.
  • Run one forecast per metric, for example table sizes, inode usage or quota.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.