Log incidents even when alerts are muted
This commit is contained in:
@@ -47,14 +47,22 @@ async def notify(
|
|||||||
category: str | None = None,
|
category: str | None = None,
|
||||||
):
|
):
|
||||||
alerts_cfg = cfg.get("alerts", {})
|
alerts_cfg = cfg.get("alerts", {})
|
||||||
|
suppressed_reason = None
|
||||||
if category and is_muted(category):
|
if category and is_muted(category):
|
||||||
return
|
suppressed_reason = "muted"
|
||||||
if category and is_auto_muted(cfg, category):
|
elif category and is_auto_muted(cfg, category):
|
||||||
return
|
suppressed_reason = "auto_mute"
|
||||||
if _in_quiet_hours(alerts_cfg):
|
elif _in_quiet_hours(alerts_cfg):
|
||||||
allow_critical = bool(alerts_cfg.get("quiet_hours", {}).get("allow_critical", True))
|
allow_critical = bool(alerts_cfg.get("quiet_hours", {}).get("allow_critical", True))
|
||||||
if not (allow_critical and level == "critical"):
|
if not (allow_critical and level == "critical"):
|
||||||
return
|
suppressed_reason = "quiet_hours"
|
||||||
|
|
||||||
|
if suppressed_reason:
|
||||||
|
try:
|
||||||
|
log_incident(cfg, f"[suppressed:{suppressed_reason}] {text}", category=category)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return
|
||||||
|
|
||||||
dedup_sec = int(alerts_cfg.get("notify_cooldown_sec", alerts_cfg.get("cooldown_sec", 900)))
|
dedup_sec = int(alerts_cfg.get("notify_cooldown_sec", alerts_cfg.get("cooldown_sec", 900)))
|
||||||
if dedup_sec > 0:
|
if dedup_sec > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user