Repository navigation
feat: ad hoc filter finishing touches - #3658
Conversation
🦋 Changeset detectedLatest commit: 0f16331 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor 2 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This flag-gated change ( 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (11): correctness, adversarial, security, testing, maintainability, project-standards, api-contract, kieran-typescript, previous-comments, agent-native, learnings-researcher. Testing gaps: Consider an explicit test that loading a dashboard whose stored ad hoc filter lacks No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 465 passed • 1 skipped • 1292s
Tests ran across 4 shards in parallel. |
| /** | ||
| * Operators an ad hoc filter condition can use, spelled as in PromQL so one set | ||
| * serves both source types. See `SQL_ADHOC_FILTER_OPERATORS` and | ||
| * `PROMQL_ADHOC_FILTER_OPERATORS` for which ones each source type supports. | ||
| */ |
There was a problem hiding this comment.
The comment here is a little out of date now, or maybe =| and IN should be a single shared operator, like regex is?
There was a problem hiding this comment.
Yeah, I was thinking about just making a single operator. I think that's a good idea
pulpdrew
left a comment
There was a problem hiding this comment.
LGTM, with a minor suggestion for consistency
- Add IN (SQL) and =| (PromQL) operators; conditions on the same key are OR'd into one IN (...) or =~"a|b" condition. - Ad hoc filters always broadcast (isBroadcastEnabled: z.literal(true)), and their variable name is a unique identifier only, no longer declared as a $variable. - Warn when another ad hoc filter already applies to the same sources. - Collapse the filter input to three conditions behind a "+N more" toggle.
One predicate decides whether a filter's name is a referenceable variable, used by getDashboardVariableFilters, getFilterEffect, and the filters list. Updates the ad hoc filter e2e specs for the removed broadcast checkbox and the list no longer showing an ad hoc filter's name as a variable.
7070a05 to
0f16331
Compare
Summary
Finishing touches for ad hoc dashboard filters, which are still behind
NEXT_PUBLIC_ENABLE_ADHOC_FILTERS.$name, but its name still has to be unique because it keys the filter's conditions in thefilters=URL param. The edit form now says so. The filter-bar tooltip and the filters list no longer present it as a variable.getDashboardVariableFiltersskips ad hoc filters, so checkAlerts, MCP validation and the alert chart stop declaring them.isVariableEnabled: truestays, because name-uniqueness validation reads it.isBroadcastEnabled: z.literal(true), the same waySTATIC_LISTandPROMETHEUS_LABELusez.literal(false). The edit form drops the broadcast checkbox and always shows "Applies to sources".INoperator. Each condition still holds one key and one value. When rendered,INconditions sharing a key are OR'd: SQL renderstoString(key) IN ('a', 'b')and PromQL renderskey=~"a|b", with regex characters escaped. It is one stored value for both source types; the PromQL condition editor labels it=|, as Grafana does. A condition the filter's source type can't express (LIKEon PromQL) is skipped and its chip is marked invalid.Compatibility: an ad hoc filter already stored with
isBroadcastEnabled: false, or without the field, will no longer parse. The feature is behind a flag, so there is no migration.Screenshots or video
I couldn't capture screenshots from my environment. @aaronknudtson, please add before/after shots of the ad hoc filter edit modal and of a filter input holding more than 3 conditions.
How to reproduce
Starting point:
yarn dev.packages/app/.env.developmentsetsNEXT_PUBLIC_ENABLE_ADHOC_FILTERS=true.On
main:inoption.On this branch:
ServiceName in apiandServiceName in web. Tiles on Logs filter withtoString(ServiceName) IN ('api', 'web'). On a Prometheus ad hoc filter,=|(stored asIN) conditions on the same label render aslabel=~"(a|b)".How to test on Vercel preview
N/A. The preview builds without
NEXT_PUBLIC_ENABLE_ADHOC_FILTERS, so ad hoc filters aren't offered there.Preview routes: N/A
Steps:
References