Repository navigation
Description
Alert Rules: integrate built-in spike/quota alerts into AlertRule
Parent
- Alert rules: configurable conditions and destinations #493 — Alert Rules vision
Depends on
- Alert Rules foundation
- Extended condition support from Alert Rules: additional conditions + scheduled evaluator #534 where required
Goal
Unify the existing built-in error-spike and quota alert settings with the AlertRule engine without changing current notification behavior or causing duplicate alerts.
After this migration, AlertRule should become the canonical representation for these alerts, or there must be a clearly documented transitional dual-read strategy.
Background
The dashboard currently exposes built-in alert shortcuts through Project.alert_settings, including:
- error-spike alerts
- quota warning / exceeded alerts
Custom rules are stored and evaluated separately through AlertRule.
This slice should converge those paths while preserving the behavior users already rely on.
Scope
Canonical rule representation
Represent built-in alert settings as AlertRule rows or an equivalent rule-engine-native model.
Define mappings for at least:
- error-spike enabled state
- error-spike threshold
- error-spike evaluation window
- quota warning enabled state
- quota warning percentage
- quota exceeded behavior
- cooldown behavior
- notification destinations
Document which built-in settings map directly to rule conditions and which require special compatibility handling.
Migration strategy
Implement one explicit migration strategy:
Preferred: migrate to AlertRule
- Create equivalent
AlertRulerows from existingProject.alert_settings - Make the migration safe to run more than once
- Avoid creating duplicate built-in rules
- Preserve disabled configurations
- Preserve existing thresholds and windows
- Record enough metadata to identify system-managed built-in rules
Transitional alternative: dual-read
When an immediate full migration is unsafe:
- read both legacy settings and
AlertRulerows - ensure only one path can fire for the same logical alert
- define precedence when both representations exist
- document how and when the legacy path will be removed
Dual-read must be temporary and must not create two independent sources of truth indefinitely.
System-managed rules
Built-in rules should be distinguishable from user-created custom rules.
Consider fields or metadata such as:
- rule source:
SYSTEM/CUSTOM - built-in kind:
ERROR_SPIKE/QUOTA_WARNING/QUOTA_EXCEEDED - stable migration key
- whether the rule may be deleted or only disabled
The dashboard must not accidentally allow users to convert a system-managed rule into an invalid or unsupported configuration.
Notification behavior
Preserve current user-visible behavior:
- same notification categories
- same recipients and destinations
- same alert titles and essential payload data where practical
- same cooldown behavior
- same quota-warning and quota-exceeded semantics
- no duplicate notification for one logical alert occurrence
All delivery must continue through:
fireProjectAlert- Notifications enqueue paths
Rules must not send directly to Slack, Discord, email, webhooks, or other providers.
Dedupe compatibility
Preserve the logical meaning of existing dedupe keys.
Requirements:
- migration must not cause an already-fired alert to immediately fire again
- legacy and rule-engine paths must not generate separate dedupe identities for the same occurrence
- quota warning and quota exceeded alerts must remain distinguishable
- retries must remain idempotent
- concurrent evaluation must not enqueue duplicate notifications
Where exact legacy dedupe keys cannot be retained, document and test the compatibility strategy.
Dashboard compatibility
Existing built-in controls should continue to work during the transition.
Choose and document one UX model:
- built-in controls edit their corresponding system-managed
AlertRulerows; or - built-in controls are replaced by links or presets in the Alert Rules UI.
Users must not see conflicting state between:
- built-in alert settings
- custom rule rows
- notification preferences
Operator and rollout path
Document:
- migration command or deployment step
- whether a database backfill is required
- how the migration can be safely retried
- rollout order
- fallback or rollback behavior
- when legacy reads/writes may be removed
- how to identify projects that failed migration
- any metrics or logs used to verify the rollout
The application must remain functional during mixed-version deployments where old and new application instances may briefly run at the same time.
Acceptance criteria
- Existing error-spike settings have an equivalent rule-engine representation
- Existing quota warning/exceeded settings have an equivalent rule-engine representation
- Migration or backfill is idempotent
- Disabled legacy settings remain disabled
- Existing thresholds, windows, and cooldowns are preserved
- System-managed rules are distinguishable from custom rules
- Running the migration more than once does not create duplicate rules
- Legacy and new evaluation paths cannot both fire for the same logical alert
- Existing dedupe behavior is preserved or explicitly compatibility-mapped
- Previously fired alerts do not immediately re-fire solely because of migration
- Notification delivery still uses only
fireProjectAlert/ Notifications enqueue paths - Built-in dashboard controls remain consistent with the canonical rule state
- Migration, mixed-deployment, and rollback behavior are documented
- Unit and integration tests cover migration, evaluation, dedupe, and RBAC behavior
- Legacy code removal is tracked in a follow-up issue if not completed here
Required test coverage
At minimum, cover:
- project with error-spike enabled
- project with error-spike disabled
- project with quota warning enabled
- project with quota alerts disabled
- project with both built-in alert types enabled
- project that already has migrated system rules
- migration executed twice
- legacy and migrated evaluator running against the same project
- cooldown-active alert during migration
- quota warning vs quota exceeded dedupe identities
- archived or deleted project
- notification enqueue failure and retry
- concurrent evaluator execution
- dashboard update of a system-managed rule
Out of scope
- New notification providers
- Provider-specific delivery logic
- Release Health alert rules
- New condition evaluators unrelated to error-spike or quota integration
- Removal of all legacy compatibility code unless explicitly included in this slice
Activity
Merge pull request #544 from Telemetry-Tracker/feat/alert-rules-built…
Release prep v1.15.2: CHANGELOG + API_VERSION for Alert Rules Telemet…