From 69d121aa0743b3b1319ddc14a2834a91bfdefa25 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Tue, 27 Jan 2026 18:54:05 -0300 Subject: [PATCH] atlasbot: use hottest node labels for insights --- services/comms/atlasbot-deployment.yaml | 2 +- services/comms/scripts/atlasbot/bot.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/services/comms/atlasbot-deployment.yaml b/services/comms/atlasbot-deployment.yaml index 2c0b84d..1212505 100644 --- a/services/comms/atlasbot-deployment.yaml +++ b/services/comms/atlasbot-deployment.yaml @@ -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" diff --git a/services/comms/scripts/atlasbot/bot.py b/services/comms/scripts/atlasbot/bot.py index 659ea49..7f92d8e 100644 --- a/services/comms/scripts/atlasbot/bot.py +++ b/services/comms/scripts/atlasbot/bot.py @@ -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: