atlasbot: use hottest node labels for insights

This commit is contained in:
Brad Stein 2026-01-27 18:54:05 -03:00
parent 79650616f1
commit 69d121aa07
2 changed files with 17 additions and 5 deletions

View File

@ -16,7 +16,7 @@ spec:
labels:
app: atlasbot
annotations:
checksum/atlasbot-configmap: manual-atlasbot-58
checksum/atlasbot-configmap: manual-atlasbot-59
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "comms"
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"

View File

@ -1608,14 +1608,26 @@ def _insight_candidates(
hottest = metrics.get("hottest_nodes") if isinstance(metrics.get("hottest_nodes"), dict) else {}
if hottest:
def _hot_node(entry: dict[str, Any]) -> str:
if not isinstance(entry, dict):
return ""
return (
entry.get("node")
or entry.get("label")
or (entry.get("metric") or {}).get("node")
or ""
)
cpu = hottest.get("cpu") if isinstance(hottest.get("cpu"), dict) else {}
if cpu.get("node") and cpu.get("value") is not None:
cpu_node = _hot_node(cpu)
if cpu_node and cpu.get("value") is not None:
value_fmt = _format_metric_value(str(cpu.get("value")), percent=True)
candidates.append(("cpu", f"The busiest CPU right now is {cpu.get('node')} at about {value_fmt}.", "high"))
candidates.append(("cpu", f"The busiest CPU right now is {cpu_node} at about {value_fmt}.", "high"))
ram = hottest.get("ram") if isinstance(hottest.get("ram"), dict) else {}
if ram.get("node") and ram.get("value") is not None:
ram_node = _hot_node(ram)
if ram_node and ram.get("value") is not None:
value_fmt = _format_metric_value(str(ram.get("value")), percent=True)
candidates.append(("ram", f"RAM usage peaks on {ram.get('node')} at about {value_fmt}.", "high"))
candidates.append(("ram", f"RAM usage peaks on {ram_node} at about {value_fmt}.", "high"))
postgres_line = _postgres_summary_line(metrics)
if postgres_line: