fix(api): bound alert history lookback by check interval#2515
fix(api): bound alert history lookback by check interval#2515satyasai1916 wants to merge 3 commits into
Conversation
Replace the fixed 7-day getPreviousAlertHistories scan with an interval-based narrow window (with floor and 7-day fallback) to reduce MongoDB index scans on the alert checker hot path. Fixes hyperdxio#2434 Co-authored-by: Cursor <cursoragent@cursor.com>
|
@satyasai1916 is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: eef46f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Greptile SummaryReplaces the hard-coded 7-day lookback in
Confidence Score: 5/5Safe to merge; the narrow-window optimisation is additive and the fallback preserves existing behaviour for gap-recovery scenarios. The two-phase narrow→fallback logic is correct for all reachable cases: alerts with recent history get one aggregation, alerts with older-than-narrow history fall back correctly via the exists() guard, and alerts with no history at all skip the wide query entirely. The computeAlertHistoryLookbackMs formula is verified by unit tests for every distinct range (floor, mid, cap). No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "fix(api): prettier formatting in checkAl..." | Re-trigger Greptile |
Use a cheap exists check before the 7-day fallback so new alerts without any history only run one aggregation per tick. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@satyasai1916 One of the lint jobs is failing, could you please take a look |
Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
getPreviousAlertHistorieswith an interval-based narrow window (5x check interval, 1h floor).Fixes #2434
Test plan
computeAlertHistoryLookbackMsvaluesgetPreviousAlertHistoriessuite + fallback case