atlasbot: return structured cluster summaries
This commit is contained in:
parent
b7792d30f1
commit
631bd09778
@ -16,7 +16,7 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: atlasbot
|
app: atlasbot
|
||||||
annotations:
|
annotations:
|
||||||
checksum/atlasbot-configmap: manual-atlasbot-48
|
checksum/atlasbot-configmap: manual-atlasbot-49
|
||||||
vault.hashicorp.com/agent-inject: "true"
|
vault.hashicorp.com/agent-inject: "true"
|
||||||
vault.hashicorp.com/role: "comms"
|
vault.hashicorp.com/role: "comms"
|
||||||
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"
|
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"
|
||||||
|
|||||||
@ -1268,7 +1268,17 @@ def structured_answer(
|
|||||||
node_regex = "|".join([n["name"] for n in scoped])
|
node_regex = "|".join([n["name"] for n in scoped])
|
||||||
expr = _apply_node_filter(expr, node_regex)
|
expr = _apply_node_filter(expr, node_regex)
|
||||||
res = vm_query(expr, timeout=20)
|
res = vm_query(expr, timeout=20)
|
||||||
answer = _format_metric_answer(entry, res)
|
answer = ""
|
||||||
|
if op == "top" or "hottest" in (entry.get("panel_title") or "").lower():
|
||||||
|
node, val = _primary_series_metric(res)
|
||||||
|
if node and val is not None:
|
||||||
|
percent = _metric_expr_uses_percent(entry)
|
||||||
|
value_fmt = _format_metric_value(val or "", percent=percent)
|
||||||
|
metric_label = (metric or "").upper()
|
||||||
|
label = f"{metric_label} node" if metric_label else "node"
|
||||||
|
answer = f"Hottest {label}: {node} ({value_fmt})."
|
||||||
|
if not answer:
|
||||||
|
answer = _format_metric_answer(entry, res)
|
||||||
if answer:
|
if answer:
|
||||||
scope_parts: list[str] = []
|
scope_parts: list[str] = []
|
||||||
if include_hw:
|
if include_hw:
|
||||||
@ -1292,8 +1302,8 @@ def structured_answer(
|
|||||||
percent = _metric_expr_uses_percent(entry)
|
percent = _metric_expr_uses_percent(entry)
|
||||||
base_val_fmt = _format_metric_value(base_val or "", percent=percent)
|
base_val_fmt = _format_metric_value(base_val or "", percent=percent)
|
||||||
overall_note = f" Overall hottest node: {base_node} ({base_val_fmt})."
|
overall_note = f" Overall hottest node: {base_node} ({base_val_fmt})."
|
||||||
return f"Among {scope} nodes, {answer}{overall_note}"
|
return _format_confidence(f"Among {scope} nodes, {answer}{overall_note}", "high")
|
||||||
return answer
|
return _format_confidence(answer, "high")
|
||||||
if metrics_summary:
|
if metrics_summary:
|
||||||
return metrics_summary
|
return metrics_summary
|
||||||
|
|
||||||
@ -1408,7 +1418,7 @@ def _os_mix_line(snapshot: dict[str, Any] | None) -> str:
|
|||||||
os_name = (node.get("os") or "").strip()
|
os_name = (node.get("os") or "").strip()
|
||||||
if os_name:
|
if os_name:
|
||||||
counts[os_name] += 1
|
counts[os_name] += 1
|
||||||
if not counts:
|
if not counts or (len(counts) == 1 and "linux" in counts):
|
||||||
return ""
|
return ""
|
||||||
parts = [f"{os_name}={count}" for os_name, count in sorted(counts.items(), key=lambda item: (-item[1], item[0]))]
|
parts = [f"{os_name}={count}" for os_name, count in sorted(counts.items(), key=lambda item: (-item[1], item[0]))]
|
||||||
return "OS mix: " + ", ".join(parts[:5]) + "."
|
return "OS mix: " + ", ".join(parts[:5]) + "."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user