feat(status): what is wrong first — down monitors and active alerts, and since when (#5120)
#5120 "Status page: what is wrong first". - A "Needs attention" card heads the Status board: each down monitor with how long it has been down, and each active alert (firing, acknowledged, pending, no data) with its condition and how long, linking to its history. - StatusEntry.since / since_at_least: when the current up/down run began, from the recent checks (streak_start); "for at least" when every check we have agrees. - Counts as stat tiles (Down, Active alerts, Pending, Up); names wrap instead of being cut off; dots carry their label. - Uptime and TLS are coloured by status_class against Settings → Thresholds instead of literal cutoffs; heartbeat pills and DOWN/UP use tokens and status_badge rather than hex and bold. - tests/core/test_status_page.py: streak_start cases, and the rows render with the problem card before the list, each since-time, threshold tones and no hex colour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,10 @@ class StatusEntry:
|
||||
spark_svg: str = "" # filled by the route via sparkline_svg()
|
||||
tls_days: float | None = None # days until TLS expiry (http only)
|
||||
detail_url: str | None = None
|
||||
# When the current up/down state began, as far as the recent checks show;
|
||||
# since_at_least means every check we have agrees, so it began earlier.
|
||||
since: datetime | None = None
|
||||
since_at_least: bool = False
|
||||
|
||||
|
||||
StatusSource = Callable[[object], Awaitable[list[StatusEntry]]]
|
||||
@@ -158,6 +162,17 @@ async def _uptime_by_monitor(db, monitor_ids: list[str]) -> dict[str, dict]:
|
||||
return out
|
||||
|
||||
|
||||
def streak_start(results) -> tuple[datetime | None, bool]:
|
||||
"""(checked_at of the first check in the latest run of the same result,
|
||||
whether that run fills every check given). Results are oldest-first."""
|
||||
if not results:
|
||||
return None, False
|
||||
i = len(results) - 1
|
||||
while i > 0 and results[i - 1].is_up == results[-1].is_up:
|
||||
i -= 1
|
||||
return results[i].checked_at, i == 0
|
||||
|
||||
|
||||
def _heartbeat_title(mtype: str, r) -> str:
|
||||
"""Type-aware tooltip for one heartbeat cell."""
|
||||
ts = f"{r.checked_at:%H:%M:%S} UTC"
|
||||
@@ -191,6 +206,7 @@ async def monitor_status_source(db) -> list[StatusEntry]:
|
||||
rows = recent.get(m.id, [])
|
||||
latest = rows[-1] if rows else None
|
||||
status = "pending" if latest is None else ("up" if latest.is_up else "down")
|
||||
since, since_at_least = streak_start(rows)
|
||||
tls_days = None
|
||||
if latest and latest.tls_expires_at:
|
||||
tls_days = (latest.tls_expires_at - now).total_seconds() / 86400.0
|
||||
@@ -203,5 +219,6 @@ async def monitor_status_source(db) -> list[StatusEntry]:
|
||||
latency_ms=latest.response_ms if latest else None,
|
||||
spark=[r.response_ms for r in rows if r.response_ms is not None],
|
||||
tls_days=tls_days, detail_url="/monitors/",
|
||||
since=since, since_at_least=since_at_least,
|
||||
))
|
||||
return entries
|
||||
|
||||
Reference in New Issue
Block a user