Fix/auto resolve grouped alerts#2624
Conversation
…and update webhook dependency check to filter by type
…otification resolution logic
Deep Review✅ No critical issues found. The core state-machine fix is sound: 🟡 P2 — recommended
🔵 P3 nitpicks (6)
Reviewers (8): correctness, adversarial, security, testing, reliability, kieran-typescript, maintainability, project-standards. Testing gaps:
|
|
Thanks for the contribution, overall LGTM! One change to flag during testing: Same-tick breach-then-recover fires two notifications When one evaluation tick backfills multiple buckets and a group breaches in an early bucket but recovers by the final bucket, the run sends two notifications: an I actually think the two-notification behaviour is the right default here, silently auto-resolving would hide that a threshold was crossed at all, and "it breached at 22:05 and has since recovered" is useful for on-call awareness and postmortems. So let's keep it as-is. The one thing I'd ask before merge: since this is now intentional (and easy to accidentally regress into a silent resolve later), let's pin it with a regression test that asserts both the count and the order: Open to being talked out of it though - if you feel two back-to-back messages read as flapping and would rather collapse to a single ALERT that notes the value is already back to normal, I'm fine with that direction too. But absent a strong case, let's keep both + add the test. |
@brandon-pereira agreed, I've added the regression test to pin the two notification behaviors, the test simulates a single evaluation tick processing back to back breach and recovery buckets, asserting that both the ALERT and RESOLVED notifications are emitted in the correct order and that the final persisted state correctly settles back to OK. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ng grouped alerts
…ving the single-notification constraint during breaches
…ebhook call on resolution
|
@Aryainguz can you please check the failing integration test when you get time? thank you! |
@brandon-pereira The zero-fill test was asserting the wrong final state. Period 3 has 1 log and the alert fires when
|
brandon-pereira
left a comment
There was a problem hiding this comment.
LGTM - thanks for the contribution!

The Bug
When an alert with a
Group Byclause evaluates multiple time windows (buckets) in a single cron execution tick, if the first bucket triggered anALERT, but the last bucket did not exceed the threshold, the alert history state was never explicitly reset toOKinside the evaluation loop.Fixes #2623
As a result, the alert history retained the
ALERTstate for that tick, failing to trigger thesendNotificationIfResolvedlogic. The alert remained permanently stuck in theALERTstate even after the underlying metrics returned to normal levels. (See the original developerTODOatpackages/api/src/tasks/checkAlerts/index.ts:1293calling out this edge case).The Fix
Implemented the explicit state reset inside the threshold evaluation
elseblock:Verification
OK.checkAlertstest suite.@hyperdx/api: patch).Local Validations :