fix(alerts): expose alertmanager webhook request metrics
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 2m0s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 2m0s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
## 2026-07-02 — 20:42 P0-006 Alertmanager webhook request counter exposure gap
|
||||
|
||||
**完成內容**:
|
||||
- 補上 `/api/v1/webhooks/alertmanager` route-level metrics:所有主要 return path 現在都會 once-only 呼叫 `record_webhook_request("alertmanager", "success" / "error", latency)`。
|
||||
- 覆蓋 success path:no-firing payload、CI/CD simple alert、grouped skip、converged recurrence、TYPE-1 info notification、LLM inflight suppressed、background analysis accepted。
|
||||
- 覆蓋 error path:external IP reject 與 degraded accepted response;metric 寫入失敗時只記 warning,不阻斷 webhook 回應,避免 Alertmanager retry storm。
|
||||
- 新增 `apps/api/tests/test_alertmanager_webhook_metrics.py`,直接驗證 no-firing success 與 external reject error 都會讓 `awoooi_webhook_requests_total{source="alertmanager",status="..."}` 出現在 `generate_latest()` scrape output。
|
||||
|
||||
**驗證**:
|
||||
- `DATABASE_URL=postgresql+asyncpg://test:test@localhost/test PYTHONPATH=apps/api python3.11 -m pytest apps/api/tests/test_alertmanager_webhook_metrics.py apps/api/tests/test_alertmanager_project_context.py -q -p no:cacheprovider`:`5 passed`。
|
||||
- `python3.11 -m py_compile apps/api/src/api/v1/webhooks.py apps/api/tests/test_alertmanager_webhook_metrics.py`:通過。
|
||||
- `python3 ops/runner/guard-gitea-runner-pressure.py --root .`:`GITEA_RUNNER_PRESSURE_GUARD_OK ... auto_branch_events_on_110=0 generic_runner_labels=0`。
|
||||
- `git diff --check`:通過。
|
||||
|
||||
**仍維持**:
|
||||
- 未讀 Telegram token / secret / `.env` / raw sessions / SQLite / auth;未送 controlled probe;未 workflow_dispatch;未重啟主機 / VM / Docker daemon / Nginx / K3s / DB / firewall;未寫 production DB。
|
||||
|
||||
## 2026-07-02 — 20:18 CIR-P0-TG-001 Telegram alert learning registry readback
|
||||
|
||||
**完成內容**:
|
||||
|
||||
Reference in New Issue
Block a user