feat(timeline): one record of what happened to the infrastructure, newest first (#6348)
A stored log, timeline_entries, with one row per thing that happened. Each source writes its row in the same transaction as its own record, so the history outlives the 30/90/365-day retention of the tables it points to: - alert events (core/alerts._add_event): fired, resolved, acknowledged, went silent, readings back; - finished Ansible runs (executor, and the startup sweep of interrupted runs): changed something, changed nothing, failed, dry run; - audit rows (core/audit.log_audit): Steward's settings, users and access, sign-ins, backups. Actions another writer records are left to it. Entries carry a kind (fixed) and an area (Service, Host OS, Hardware, Storage, Network, Security, Monitoring). Settings → Timeline edits the areas and each type's area and visibility; both are applied when the timeline is read, so a change re-sorts past entries and a hidden type comes back when shown. Kept forever unless a retention is set. The first start fills the timeline from the last 90 days of records once, skipping any already covered. A host rename carries its entries. UI: Timeline in the sidebar (filter by host, area, kind; scrolls on), a History card on each host page. MCP: get_timeline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING
|
||||
from sqlalchemy import delete
|
||||
|
||||
from steward.core.anomalies import prune as prune_anomalies
|
||||
from steward.timeline.service import prune as prune_timeline
|
||||
from steward.models.alerts import AlertEvent
|
||||
from steward.models.ansible import AnsibleRun
|
||||
from steward.models.audit import AuditEvent
|
||||
@@ -81,6 +82,10 @@ async def run_cleanup(app: "Quart") -> dict:
|
||||
pruned = await prune_anomalies(session, cutoff)
|
||||
removed.append([f"metric_anomalies: reviewed, ended over {data_days} days ago",
|
||||
pruned])
|
||||
# The timeline keeps its own window, everything by default.
|
||||
pruned, days = await prune_timeline(session, now)
|
||||
if days:
|
||||
removed.append([f"timeline_entries: older than {days} days", pruned])
|
||||
|
||||
files = await asyncio.to_thread(prune_run_logs, ARTIFACT_DIR, cutoff)
|
||||
removed.append([f"Ansible run log files: older than {data_days} days", files])
|
||||
|
||||
Reference in New Issue
Block a user