Skip to content

feat: Add additional alert threshold types#2122

Merged
kodiakhq[bot] merged 8 commits intomainfrom
drew/alert-thresholds
Apr 16, 2026
Merged

feat: Add additional alert threshold types#2122
kodiakhq[bot] merged 8 commits intomainfrom
drew/alert-thresholds

Conversation

@pulpdrew
Copy link
Copy Markdown
Contributor

@pulpdrew pulpdrew commented Apr 15, 2026

Summary

This PR adds new types of alert thresholds: >, <=, =, and !=.

Screenshots or video

Screen.Recording.2026-04-15.at.10.20.08.AM.mov

How to test locally or on Vercel

This must be tested locally, since alerts are not supported in the preview environment.

To see the notification content, run an echo server locally and create a webhook that targets it (http://localhost:3000):

npx http-echo-server

References

  • Linear Issue: Closes HDX-3988
  • Related PRs:

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: ea17923

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/api Patch
@hyperdx/app Patch
@hyperdx/cli Patch
@hyperdx/otel-collector Patch

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

@github-actions github-actions bot added the review/tier-4 Critical — deep review + domain expert sign-off label Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔴 Tier 4 — Critical

Touches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD.

Why this tier:

  • Critical-path files (4):
    • packages/api/src/routers/external-api/v2/alerts.ts
    • packages/api/src/tasks/checkAlerts/__tests__/checkAlerts.test.ts
    • packages/api/src/tasks/checkAlerts/index.ts
    • packages/api/src/tasks/checkAlerts/template.ts

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Files changed: 18
  • Lines changed: 236 (+ 1099 in test files, excluded from tier calculation)
  • Branch: drew/alert-thresholds
  • Author: pulpdrew

To override this classification, remove the review/tier-4 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Apr 16, 2026 3:35pm

Request Review

@pulpdrew pulpdrew added review/tier-3 Standard — full human review required and removed review/tier-4 Critical — deep review + domain expert sign-off labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

PR Review

PR: feat: Add additional alert threshold types (>, <=, =, !=)

  • ⚠️ Floating-point strict equality in doesExceedThreshold (packages/api/src/tasks/checkAlerts/index.ts:155) uses value === threshold for EQUAL and value !== threshold for NOT_EQUAL. ClickHouse metric queries can return floats (e.g. 0.1 + 0.2 → 0.30000000000000004), so these alerts may silently misfire for non-integer thresholds. The UI warning at TileAlertEditor.tsx:225 documents this, but the backend has no mitigation. Consider documenting this limitation more explicitly in the API schema, or adding a tolerance-based comparison (even a very small epsilon) for metric tile alerts.

  • ⚠️ NOT_EQUAL always fires on missing data (checkAlerts/index.ts:1012): when no data is returned for a bucket, doesExceedThreshold(NOT_EQUAL, threshold, 0) returns true whenever threshold !== 0. This means a NOT_EQUAL alert with any non-zero threshold will continuously fire during data gaps, which may be very noisy. This is consistent with how BELOW behaves (also fires on missing data if threshold > 0), but the behavior is likely more surprising for NOT_EQUAL. Worth a code comment or documentation note.

  • AlertThresholdType enum correctly moved to common-utils with a re-export from the old location for backward compatibility.

  • ✅ Exhaustive switch statements in both doesExceedThreshold and describeThreshold* functions — TypeScript will catch missing cases.

  • ✅ Comprehensive unit + integration tests covering boundary values (equal, just-above, just-below) for all four new types.

  • ✅ OpenAPI spec updated to include new enum values.

@pulpdrew pulpdrew force-pushed the drew/alert-thresholds branch from 9b44f74 to c0dd8c9 Compare April 15, 2026 14:28
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

E2E Test Results

All tests passed • 134 passed • 3 skipped • 1058s

Status Count
✅ Passed 134
❌ Failed 0
⚠️ Flaky 2
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew requested review from a team and teeohhem and removed request for a team April 15, 2026 14:38
Comment thread packages/api/src/tasks/checkAlerts/template.ts
Comment thread packages/api/src/tasks/checkAlerts/index.ts Outdated
Comment thread packages/api/src/tasks/checkAlerts/template.ts Outdated
@kodiakhq kodiakhq bot merged commit d3a61f9 into main Apr 16, 2026
27 of 29 checks passed
@kodiakhq kodiakhq bot deleted the drew/alert-thresholds branch April 16, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants