fix(monitoring): classify host memory pressure accurately

This commit is contained in:
ogt
2026-07-15 06:15:13 +08:00
parent 89595a7d8d
commit 5c0c5f6da2
11 changed files with 76 additions and 25 deletions

View File

@@ -2661,7 +2661,7 @@ def _build_host_sustained_load_controlled_automation_readback() -> dict[str, Any
},
{
"class_id": "memory_or_swap_pressure",
"alertnames": ["HostLoadAverageSustainedHigh", "HostOutOfMemory"],
"alertnames": ["HostLoadAverageSustainedHigh", "HostMemoryUsageHigh", "HostOutOfMemory"],
"classifier": "host-sustained-load-controller.py:blocked_memory_or_swap_pressure_requires_service_playbook",
"controlled_action": "route to service-specific memory/cgroup playbook with check-mode diff",
"controlled_apply_allowed": False,

View File

@@ -960,6 +960,7 @@ async def _resolve_target_from_k8s(incident: "Incident", namespace: str) -> str
# 並加 log 便於追蹤 fallback 路徑
_ALERTNAME_KEYWORDS: dict[str, list[str]] = {
"HostHighCpuLoad": ["api", "web"],
"HostMemoryUsageHigh": ["api", "web"],
"HostOutOfMemory": ["api", "web"],
"DockerContainerUnhealthy": [],
"DockerContainerExited": [],
@@ -1064,7 +1065,7 @@ async def _fetch_metrics_snapshot(incident: Incident) -> dict:
snapshots: dict = {}
# 根據 alertname 選擇最相關的指標
if alertname in ("HostHighCpuLoad", "HostOutOfMemory"):
if alertname in ("HostHighCpuLoad", "HostMemoryUsageHigh", "HostOutOfMemory"):
if instance:
host = instance.split(":")[0]
# P0 fix 2026-04-11: _instant_query 要求 dict回傳 {"result": [...]}