diff --git a/apps/api/src/api/v1/webhooks.py b/apps/api/src/api/v1/webhooks.py index e86950f11..c73255a0e 100644 --- a/apps/api/src/api/v1/webhooks.py +++ b/apps/api/src/api/v1/webhooks.py @@ -841,26 +841,19 @@ async def receive_alert( if updated_approval: # ================================================================= - # [關鍵修復] 收斂告警也必須推送 Telegram (BackgroundTasks) + # 2026-03-27 ogt: 收斂告警不重複發送 Telegram,只更新 hit_count + # 避免 Telegram 洗版,用戶可在 UI 查看聚合次數 # ================================================================= - background_tasks.add_task( - _push_to_telegram_background, + logger.info( + "alert_converged_telegram_skipped", approval_id=str(updated_approval.id), - risk_level=updated_approval.risk_level.value, - resource_name=alert.target_resource, - root_cause=alert.message, - suggested_action=updated_approval.action, - estimated_downtime="~30s", hit_count=updated_approval.hit_count, - # v6.0 AI 仲裁 (收斂告警使用 COLLAB,因為跳過 LLM) - primary_responsibility="COLLAB", - confidence=0.70, # 收斂告警標準信心度 - namespace=alert.namespace, + reason="Converged alert - Telegram already sent for this fingerprint", ) return AlertResponse( success=True, - message=f"🛡️ 告警收斂:相同指紋告警已聚合 (x{updated_approval.hit_count}次),跳過 LLM", + message=f"🛡️ 告警收斂 (x{updated_approval.hit_count}) - Telegram 已發送,跳過重複通知", alert_id=alert_id, approval_created=False, # 未建立新卡片 approval_id=str(updated_approval.id), @@ -1223,23 +1216,18 @@ async def alertmanager_webhook( updated_approval = await service.increment_hit_count(existing_approval.id) if updated_approval: - background_tasks.add_task( - _push_to_telegram_background, + # 2026-03-27 ogt: 收斂告警不重複發送 Telegram,只更新 hit_count + # 用戶可在 UI 查看聚合次數,避免 Telegram 洗版 + logger.info( + "alertmanager_converged_telegram_skipped", approval_id=str(updated_approval.id), - risk_level=updated_approval.risk_level.value, - resource_name=target_resource, - root_cause=message, - suggested_action=updated_approval.action, - estimated_downtime="~30s", hit_count=updated_approval.hit_count, - primary_responsibility="COLLAB", - confidence=0.70, - namespace=namespace, + reason="Converged alert - Telegram already sent for this fingerprint", ) return AlertResponse( success=True, - message=f"🛡️ 告警收斂 (x{updated_approval.hit_count})", + message=f"🛡️ 告警收斂 (x{updated_approval.hit_count}) - Telegram 已發送,跳過重複通知", alert_id=alert_id, approval_created=False, approval_id=str(updated_approval.id),