feat(retention): every growing table is pruned; the audit log has its own window; charts read the raw window from Settings (#5155)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 47s
CI / unit (push) Successful in 1m10s
CI / publish (push) Successful in 55s

- prune_by_age(column) registers a time-series column with the hourly cleanup;
  Traefik (metrics, access summaries, global stats) and UniFi (WAN, client,
  WLAN, DPI, events, alarms, speedtests) register theirs in setup().
- Alert events join monitor results and Ansible runs on data.retention_days,
  read from Settings each run; Ansible run log files older than it are deleted.
- audit.retention_days (365) keeps the audit log longer, set on Settings > General.
- metric_series.points reads metrics.retention.raw_days, so the chart's
  raw/rollup seam is where the rollup put it (RAW_DAYS removed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 21:05:22 -04:00
co-authored by Claude Opus 5.5
parent 2f208a84fb
commit 9fdd67a675
9 changed files with 214 additions and 20 deletions
+5
View File
@@ -12,6 +12,11 @@ def setup(app: "Quart") -> None:
global _app
_app = app
from .models import TraefikMetric, TraefikCert, TraefikGlobalStat, TraefikAccessSummary # noqa: F401
from steward.core.cleanup import prune_by_age
# Samples older than data.retention_days are pruned by the cleanup (#5155).
prune_by_age(TraefikMetric.scraped_at)
prune_by_age(TraefikGlobalStat.scraped_at)
prune_by_age(TraefikAccessSummary.period_end)
def get_scheduled_tasks() -> list:
+8
View File
@@ -16,6 +16,14 @@ def setup(app: "Quart") -> None:
UnifiDevice, UnifiKnownClient, UnifiEvent, UnifiAlarm,
UnifiSpeedtestResult, UnifiNetwork, UnifiPortForward, UnifiFwRule,
)
from steward.core.cleanup import prune_by_age
# Samples and history older than data.retention_days are pruned by the
# cleanup (#5155). Devices, known clients and config tables are current state.
for column in (UnifiWanStat.scraped_at, UnifiClientSnapshot.scraped_at,
UnifiWlanStat.scraped_at, UnifiDpiSnapshot.scraped_at,
UnifiEvent.event_time, UnifiAlarm.alarm_time,
UnifiSpeedtestResult.run_at):
prune_by_age(column)
def get_scheduled_tasks() -> list: