Repository navigation
fix: deduplicate repeated Alertmanager and Grafana notifications (#124) - #147
Merged
Merged
Conversation
Both re-send a still-firing alert every group_interval/repeat_interval, after restarts and from each HA replica, and every delivery became a new incident that re-ran diagnosis and could re-apply the fix (#124). Before enqueueing, each firing alert atomically claims a marker keyed on org + fingerprint (or sorted labels) + startsAt (put_json_if_absent), and the incident is then queued under the claimed id, so concurrent deliveries cannot both get through. Repeats within ALERT_DEDUPE_WINDOW_SEC (default 3600, 0 disables) are returned as duplicate_of the original incident, with status "duplicate" when nothing new was queued. A new startsAt is a new incident. Markers live under alert_dedupe/, off the queue poll path, and are expired by retention. Fixes #124 Co-Authored-By: Claude Opus 5.5 <[email protected]>
9 of 35 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #124.
Alertmanager and Grafana re-send a still-firing alert every
group_interval/repeat_interval(4h by default), after restarts, and once per HA replica. Every delivery became a new incident: a fresh diagnosis (LLM cost), another Slack approval, possibly another PagerDuty page, and withAUTO_APPLY=true, the fix applied again (another rollback or restart).New
services/alert_dedupe.py:fingerprint(both Alertmanager and Grafana send it; a hash of the sorted labels is used when it's missing) +startsAt.put_json_if_absent(atomic on S3, GCS, Azure and memory), and only then enqueues under that ID. Two simultaneous deliveries can't both get through.ALERT_DEDUPE_WINDOW_SEC(default 3600;0disables) is not queued. It's returned underduplicate_ofwith the original incident ID, andstatusis"duplicate"when nothing new was queued.startsAt(the alert resolved and fired again) is always a new incident.{org}/alert_dedupe/, off the queue poll path (lesson from Review queue rescans every historical review, Bitbucket queues reviews for non-open pull requests, and a failed review never retries #108/fix: keep review dedupe off the poll path, require open Bitbucket PRs, and retry failed heads #109), and are expired by the existing retention job (alert_dedupeadded to its categories).{"status": "duplicate", "incident_ids": [], "duplicate_of": ["INC-20261029100000-a1b2c3"]}Response shape is backwards compatible: first deliveries still return
{"status": "queued", "incident_ids": [...]}.Type of Change
Testing
tests/test_alert_dedupe.py(21 tests):startsAtgives a new incident; mixed batch reports new and duplicate; orgs deduplicated separately; window0disables; resolved alerts ignoredstartsAtis part of identityqueue/tests/conftest.py: each test gets fresh dedupe storage (several existing tests post the same alert payload).-llclean.mkdocs build --strictplus link check: 0 errors.Docs
.env.example(ALERT_DEDUPE_WINDOW_SEC),docs/API_REFERENCE.md(repeat-notification behaviour and response),docs/GRAFANA_PROMETHEUS.md(troubleshooting row).🤖 Generated with Claude Code