fix(ops): classify systemd runner alerts as host resources
Some checks failed
CD Pipeline / tests (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
CD Pipeline / post-deploy-checks (push) Has been cancelled
Code Review / ai-code-review (push) Has been cancelled

This commit is contained in:
Your Name
2026-05-05 14:28:18 +08:00
parent a5192d4e03
commit 0e14935351
5 changed files with 61 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ OpenClaw 告警規則匹配引擎
- 規則在 YAML 定義,不需要改 Python 代碼
- 匹配邏輯: alertname 完全匹配 > alert_type 部分匹配 > message 關鍵字
- priority 越小越優先999 = 通用兜底
- 變數替換: {target} {host} {container} {instance} {job} {namespace}
- 變數替換: {target} {host} {container} {instance} {job} {namespace} {unit}
自動規則生成:
- 只有 generic_fallback 觸發時才生成(具體規則不觸發)
@@ -185,6 +185,7 @@ def _extract_vars(alert_context: dict) -> dict[str, str]:
host = instance.split(":")[0] if ":" in instance else instance
job = labels.get("job", "exporter")
namespace = alert_context.get("namespace", "awoooi-prod")
unit = labels.get("unit", "")
# GAP-A4: 多層 label 查找,由最權威到最弱
target = ""
@@ -245,6 +246,7 @@ def _extract_vars(alert_context: dict) -> dict[str, str]:
"instance": instance,
"job": job,
"namespace": namespace,
"unit": unit,
}