feat(alerts): a rule can fire when a reading rises, "rose by N" (#6724)
A rule compared a reading with a fixed number, so Synology Disk 1's bad sectors going from 3,160 to 3,392 could say nothing: a count that only grows is soon past any line. "rose by" compares each reading with the one before it, kept on the alert's state and only for such a rule. A fall (a replaced disk) doesn't fire. On the rule form, through MCP, and worded in emails, the alert sentence, history and the timeline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""Alert rules: a condition that fires on a rise, and the reading before this one.
|
||||
|
||||
Revision ID: 0049_alert_on_a_rise
|
||||
Revises: 0048_tickets
|
||||
Create Date: 2026-10-30
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0049_alert_on_a_rise"
|
||||
down_revision: Union[str, None] = "0048_tickets"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ALTER TYPE ... ADD VALUE cannot run inside a transaction block.
|
||||
with op.get_context().autocommit_block():
|
||||
op.execute("ALTER TYPE alertoperator ADD VALUE IF NOT EXISTS 'rose'")
|
||||
op.add_column("alert_states", sa.Column("last_value", sa.Float, nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Postgres can't drop an enum value; 'rose' stays in the type, unused.
|
||||
op.execute("DELETE FROM alert_rules WHERE operator = 'rose'")
|
||||
op.drop_column("alert_states", "last_value")
|
||||
Reference in New Issue
Block a user