Alerts: cooldowns survive a restart, and a connection must stay down a minute before it alerts
The alert manager kept its cooldowns and its ceiling per hour in memory, so a node that stayed down was announced again by every restart. Each delivered alert is now a row in the new alert_sent table (additive migration), loaded for the last seven days when the manager starts and pruned as new ones come in. A ledger that fails never stops an alert. The manager's clock is wall time for the same reason. A node_health "down" alert also waits 60 s (HEALTH_GRACE_S) in a pending task per node; a later event that is not "down" cancels it, as does stopping the manager, so a broker restarting with the stack alerts nobody. The cooldown used to be stamped before the ceiling per hour was checked, so an alert the ceiling held back still spent its cooldown. It is stamped only once the alert is sent now.
This commit is contained in:
@@ -586,6 +586,27 @@ class ConnectorState(SQLModel, table=True):
|
||||
updated_at: datetime = Field(default_factory=get_datetime_utc, sa_type=UTCDateTime)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Alerts sent
|
||||
#
|
||||
# What the alert manager has told someone, so its cooldowns and its ceiling per
|
||||
# hour hold across a restart. A node that stays down would otherwise be
|
||||
# announced again by every one.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class AlertSent(SQLModel, table=True):
|
||||
"""One alert that was delivered, by the key it deduplicates on."""
|
||||
|
||||
__tablename__ = "alert_sent"
|
||||
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
#: `alerts.dedup_key`: the event type and the node or flow it is about.
|
||||
key: str = Field(max_length=255)
|
||||
#: Seconds since the epoch, from the manager's own clock.
|
||||
ts: float = Field(index=True)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Worker tokens
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user