atlasbot: add node namespace lines for hotspots

This commit is contained in:
Brad Stein 2026-02-02 12:56:54 -03:00
parent 178ae5470d
commit 487c2aa762
2 changed files with 24 additions and 5 deletions

View File

@ -329,11 +329,23 @@ class AnswerEngine:
metric_facts = hottest_facts
key_facts = _merge_fact_lines(metric_facts, key_facts)
if "namespace" in lowered_q and any(term in lowered_q for term in ("hotspot", "hot spot", "hottest")):
for line in summary_lines:
if line.startswith("node_pods_top:"):
metric_facts = _merge_fact_lines([line], metric_facts)
key_facts = _merge_fact_lines([line], key_facts)
break
hotspot_node = None
if hottest_facts:
match = re.search(r"hottest_\w+_node: (?P<node>[^\s\[]+)", hottest_facts[0])
if match:
hotspot_node = match.group("node")
if hotspot_node:
for line in summary_lines:
if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line:
metric_facts = _merge_fact_lines([line], metric_facts)
key_facts = _merge_fact_lines([line], key_facts)
break
if not hotspot_node or not any(line.startswith("node_namespaces_top:") for line in metric_facts):
for line in summary_lines:
if line.startswith("node_pods_top:"):
metric_facts = _merge_fact_lines([line], metric_facts)
key_facts = _merge_fact_lines([line], key_facts)
break
if classify.get("question_type") in {"metric", "diagnostic"} and not hottest_facts and not hardware_facts:
metric_candidates = _metric_candidate_lines(summary_lines, keyword_tokens)
selected_facts = await _select_metric_facts(call_llm, normalized, metric_candidates, plan)

View File

@ -828,6 +828,13 @@ def _append_node_pods(lines: list[str], summary: dict[str, Any]) -> None:
if ns_label:
label = f"{label} ({ns_label})"
lines.append("node_pods_max: " + label)
for item in top:
node = item.get("node")
namespaces = item.get("namespaces_top") or []
if not node or not namespaces:
continue
ns_label = ", ".join([f"{name}={count}" for name, count in namespaces])
lines.append(f"node_namespaces_top: {node} ({ns_label})")
def _append_pod_issues(lines: list[str], summary: dict[str, Any]) -> None: