atlasbot: answer postgres connections via snapshot
This commit is contained in:
parent
f5ea0277f6
commit
d2144bd17f
@ -715,6 +715,27 @@ class AnswerEngine:
|
||||
)
|
||||
if node_line:
|
||||
reply = f"Hotspot node: {hotspot_node}. {node_line}."
|
||||
if "postgres" in lowered_q and any(tok in lowered_q for tok in ("connection", "connections", "db")):
|
||||
pg = None
|
||||
if isinstance(snapshot_used, dict):
|
||||
summary = snapshot_used.get("summary") if isinstance(snapshot_used.get("summary"), dict) else {}
|
||||
if summary:
|
||||
top = summary.get("top") if isinstance(summary.get("top"), dict) else {}
|
||||
pg = top.get("postgres") if isinstance(top.get("postgres"), dict) else None
|
||||
if not pg:
|
||||
metrics = snapshot_used.get("metrics") if isinstance(snapshot_used.get("metrics"), dict) else {}
|
||||
pg = metrics.get("postgres_connections") if isinstance(metrics.get("postgres_connections"), dict) else None
|
||||
if isinstance(pg, dict):
|
||||
used = pg.get("used")
|
||||
max_conn = pg.get("max")
|
||||
hottest = pg.get("hottest_db") or pg.get("hottest")
|
||||
if used is not None and max_conn is not None:
|
||||
if hottest:
|
||||
reply = f"Postgres connections: used={used}, max={max_conn}; hottest_db={hottest}."
|
||||
else:
|
||||
reply = f"Postgres connections: used={used}, max={max_conn}."
|
||||
else:
|
||||
reply = "Postgres connection data is not fully available in the snapshot."
|
||||
|
||||
if classify.get("question_type") in {"metric", "diagnostic"}:
|
||||
lowered_q = f"{question} {normalized}".lower()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user