Skip to content

fix: include saved search filters in alert queries#1882

Merged
kodiakhq[bot] merged 4 commits intomainfrom
warren/hdx-3625
Mar 13, 2026
Merged

fix: include saved search filters in alert queries#1882
kodiakhq[bot] merged 4 commits intomainfrom
warren/hdx-3625

Conversation

@wrn14897
Copy link
Copy Markdown
Member

@wrn14897 wrn14897 commented Mar 11, 2026

HDX-3625

Summary

  • Saved search alerts were ignoring the filters field when building the ClickHouse chart config in getChartConfigFromAlert
  • This caused alerts on saved searches with SQL filters (e.g., ServiceName IN ('hdx-oss-dev-api'), SeverityText IN ('info')) to evaluate against unfiltered data, producing incorrect alert results
  • Added filters: savedSearch.filters to the chart config so renderChartConfig includes filter conditions in the WHERE clause

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 1417d1f

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

This PR includes changesets to release 3 packages
Name Type
@hyperdx/api Patch
@hyperdx/app 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

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 11, 2026

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

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Mar 13, 2026 0:12am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 11, 2026

PR Review

✅ No critical issues found.

The fix is minimal and correct — adding filters: savedSearch.filters?.map(f => ({ ...f })) to getChartConfigFromAlert properly propagates saved search filters to the ClickHouse query builder. Three integration tests thoroughly verify the behavior (filter inclusion, filter exclusion, and combined where+filter cases).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 11, 2026

E2E Test Results

All tests passed • 87 passed • 3 skipped • 897s

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

Tests ran across 4 shards in parallel.

View full report →

Saved search alerts were ignoring the `filters` field when building the
ClickHouse chart config, causing alerts with SQL filters (e.g.,
ServiceName/SeverityText conditions) to evaluate against unfiltered data.
Add three integration tests verifying that saved search filters are
correctly included in alert ClickHouse queries:
- filters restrict which logs are counted
- filters that match nothing keep alert in OK state
- where clause and filters are applied together

Also fix DataCloneError in materialized view alert tests by converting
Mongoose array to plain objects before structuredClone.
],
where: savedSearch.where,
whereLanguage: savedSearch.whereLanguage,
filters: savedSearch.filters?.map(f => ({ ...f })),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to not copy mongo internal properties that fail tests for some reasons

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure a spread is enough? Could also do a deep copy via structuredClone

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shallow copy should be sufficient

@kodiakhq kodiakhq Bot merged commit e05bd6b into main Mar 13, 2026
13 of 14 checks passed
@kodiakhq kodiakhq Bot deleted the warren/hdx-3625 branch March 13, 2026 00:12
knudtty pushed a commit that referenced this pull request Apr 16, 2026
HDX-3625

## Summary
- Saved search alerts were ignoring the `filters` field when building the ClickHouse chart config in `getChartConfigFromAlert`
- This caused alerts on saved searches with SQL filters (e.g., `ServiceName IN ('hdx-oss-dev-api')`, `SeverityText IN ('info')`) to evaluate against unfiltered data, producing incorrect alert results
- Added `filters: savedSearch.filters` to the chart config so `renderChartConfig` includes filter conditions in the WHERE clause
Copilot AI pushed a commit that referenced this pull request Apr 20, 2026
HDX-3625

## Summary
- Saved search alerts were ignoring the `filters` field when building the ClickHouse chart config in `getChartConfigFromAlert`
- This caused alerts on saved searches with SQL filters (e.g., `ServiceName IN ('hdx-oss-dev-api')`, `SeverityText IN ('info')`) to evaluate against unfiltered data, producing incorrect alert results
- Added `filters: savedSearch.filters` to the chart config so `renderChartConfig` includes filter conditions in the WHERE clause
Co-authored-by: peter-leonov-ch <209667683+peter-leonov-ch@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants