feat(dashboard): a curated default layout, merged duplicate widgets, a labelled Overview (#5213)
- New installs start from widgets.RECOMMENDED, packed row by row for the enabled plugins; the edit drawer can reset a dashboard to it. - Host Agent — Resources folds into Hosts — Overview (which gains load 1m), UniFi — Devices into UniFi — Overview; migration 0032 moves existing dashboards onto the survivors. - The Overview labels what it counts (hosts, monitors up/down/pending, alerts firing) and lists firing alerts and down monitors with since-times. - Uptime polls every 5 minutes (poll_seconds) instead of every cycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
from quart import Blueprint, current_app, render_template, request
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from steward.alerts.service import active_alerts
|
||||
from steward.alerts.service import active_alerts, alert_label
|
||||
from steward.auth.middleware import require_role
|
||||
from steward.core.status import collect_status, sparkline_svg
|
||||
from steward.models.hosts import Host
|
||||
@@ -53,10 +53,23 @@ async def widget():
|
||||
entries = await collect_status(db)
|
||||
total_hosts = (await db.execute(
|
||||
select(func.count()).select_from(Host))).scalar()
|
||||
alerts = await active_alerts(db)
|
||||
up, down, pending = _summarize(entries)
|
||||
return await render_template(
|
||||
"status/widget.html",
|
||||
entries=entries, up=up, down=down, pending=pending,
|
||||
total_hosts=total_hosts,
|
||||
total_hosts=total_hosts, alerts=overview_alerts(alerts),
|
||||
widget_id=request.args.get("wid", "0"),
|
||||
)
|
||||
|
||||
|
||||
def overview_alerts(alerts) -> list[dict]:
|
||||
"""The Overview's alert lines: breaching or silent first, then those
|
||||
someone has taken; each {rule, label, since}."""
|
||||
order = {"firing": 0, "no_data": 1, "pending": 2, "acknowledged": 3}
|
||||
rows = []
|
||||
for state, rule in alerts:
|
||||
label = alert_label(state)
|
||||
since = state.no_data_since if label == "no_data" else state.last_transition_at
|
||||
rows.append({"rule": rule, "label": label, "since": since})
|
||||
return sorted(rows, key=lambda r: order.get(r["label"], 9))
|
||||
|
||||
Reference in New Issue
Block a user