snapshot: clarify restarts and longhorn

This commit is contained in:
Brad Stein 2026-01-29 08:41:53 -03:00
parent 26c6cea40b
commit 2ac95c2154

View File

@ -766,14 +766,18 @@ def _append_longhorn(lines: list[str], summary: dict[str, Any]) -> None:
if not longhorn:
return
total = longhorn.get("total")
unhealthy = longhorn.get("unhealthy_count")
attached = longhorn.get("attached_count")
detached = longhorn.get("detached_count")
degraded = longhorn.get("degraded_count")
by_state = longhorn.get("by_state") if isinstance(longhorn.get("by_state"), dict) else {}
by_robust = longhorn.get("by_robustness") if isinstance(longhorn.get("by_robustness"), dict) else {}
if total is not None:
lines.append(
"longhorn: total={total}, unhealthy={unhealthy}".format(
"longhorn: total={total}, attached={attached}, detached={detached}, degraded={degraded}".format(
total=total,
unhealthy=unhealthy if unhealthy is not None else 0,
attached=attached if attached is not None else 0,
detached=detached if detached is not None else 0,
degraded=degraded if degraded is not None else 0,
)
)
if by_state:
@ -922,6 +926,8 @@ def _append_restarts(lines: list[str], summary: dict[str, Any]) -> None:
parts.append(f"{namespace}/{pod}={count}")
if parts:
lines.append("restarts_1h_top: " + "; ".join(parts))
else:
lines.append("restarts_1h_top: none")
ns_top = metrics.get("restart_namespace_top") or []
if isinstance(ns_top, list) and ns_top:
ns_parts = []
@ -933,6 +939,8 @@ def _append_restarts(lines: list[str], summary: dict[str, Any]) -> None:
ns_parts.append(f"{namespace}={_format_float(value)}")
if ns_parts:
lines.append("restarts_1h_namespace_top: " + "; ".join(ns_parts))
else:
lines.append("restarts_1h_namespace_top: none")
def _append_job_failures(lines: list[str], summary: dict[str, Any]) -> None:
@ -1033,6 +1041,8 @@ def _append_postgres(lines: list[str], summary: dict[str, Any]) -> None:
for entry in by_db:
metric = entry.get("metric") if isinstance(entry, dict) else {}
value = entry.get("value")
if isinstance(value, list) and len(value) >= _VALUE_PAIR_LEN:
value = value[1]
name = metric.get("datname") if isinstance(metric, dict) else None
if name and value is not None:
parts.append(f"{name}={_format_float(value)}")