Add alert rule editing UI

This commit is contained in:
Keith Smith
2026-05-23 16:08:27 -06:00
parent a8a4eb84f6
commit 5c9f93692a
10 changed files with 340 additions and 47 deletions
+13
View File
@@ -144,6 +144,19 @@ class Scheduler:
)
threshold_met = len(recent_statuses) >= rule.failure_threshold and all(status != "up" for status in recent_statuses)
if threshold_met and open_incident is None:
if rule.cooldown_seconds > 0:
latest_incident = db.scalar(
select(Incident)
.where(
Incident.monitor_id == monitor.id,
Incident.alert_rule_id == rule.id,
)
.order_by(Incident.opened_at.desc())
.limit(1)
)
if latest_incident is not None and latest_incident.opened_at + timedelta(seconds=rule.cooldown_seconds) > now:
return
incident = Incident(
asset_id=monitor.asset_id,
monitor_id=monitor.id,