Add alert rule editing UI
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user