Conversation
Dashboard filter dropdowns now narrow one another: selecting a value in one filter constrains the options shown by the others to values that co-occur with the current selection (e.g. picking a cluster limits the namespace dropdown to namespaces in that cluster). Applies to both manually-created dashboards and the bundled Kubernetes page (which also honors its free-text search). A filter never constrains its own options, so multi-select within a filter still works. HDX-4462
🦋 Changeset detectedLatest commit: d6e724a 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
E2E Test Results❌ 1 test failed • 196 passed • 3 skipped • 1362s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. The faceting design is sound — constraints are AND-combined in 🟡 P2 — recommended
🔵 P3 nitpicks (6)
Reviewers (8): correctness, adversarial, testing, maintainability, kieran-typescript, julik-frontend-races, performance, project-standards. Testing gaps:
|
Greptile SummaryThis PR adds opt-in linked (faceted) filter values to the Dashboard and Kubernetes filter bars. A toggle at the end of each bar enables filter-awareness: each dropdown only shows values that co-occur with the other current selections. Lazy fetching bounds the cost — a dropdown's constrained values are only fetched when it is opened.
Confidence Score: 5/5Safe to merge; the new faceted-filter logic is well-tested, off by default, and isolated from the search-page filters. The constraint-building, batching, and lazy-fetch logic are all correctly implemented and covered by comprehensive unit tests. The two isLoading vacuous-truth edge cases and the openFilterIds stale-state edge case are minor quality issues that don't affect observable behaviour in current consumers. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant DF as DashboardFilters
participant UDFV as useDashboardFilterValues
participant OKVC as useOptimizedKeyValuesCalls
participant RQ as React Query
U->>DF: Toggle Link filters ON
DF->>UDFV: filterValues, activeFilterIds empty
Note over UDFV: No dropdowns open — no fetches
U->>DF: Open dropdown for Filter A
DF->>UDFV: activeFilterIds includes A
UDFV->>OKVC: Build constraints (sibling selections, exclude self)
OKVC->>RQ: queryKey with constraints_for_A
RQ-->>UDFV: constrained values for A
UDFV-->>DF: Map with A values
DF-->>U: Dropdown shows narrowed options
U->>DF: Select value in Filter A
DF->>UDFV: filterValues updated
Note over UDFV: Constraints for open siblings recalculated
UDFV->>OKVC: New constraint sig for open filters
OKVC->>RQ: New queryKey for affected open filters
RQ-->>UDFV: Re-narrowed values
DF-->>U: Other open dropdowns refresh
Reviews (5): Last reviewed commit: "style(dashboards): use themed 'secondary..." | Re-trigger Greptile |
stripFieldClause and extractValueFromSearchQuery interpolated the attribute name straight into a RegExp. Escape it (lodash escapeRegExp) so dots match literally instead of as wildcards, and metacharacters like '(' or '[' in a resource-attribute expression can't throw a SyntaxError.
Memoize the five FilterSelect chart configs in a single useMemo (keyed on searchQuery, dateRange, metricSource) so they keep a stable identity across re-renders unrelated to the filters, avoiding repeated React Query key serialization. (useCallback on the builder wouldn't help: calling it still mints a new object per render.)
Add tests covering literal-dot matching and the metacharacter case.
|
Outstanding discussions:
|
Add a bidirectional-arrow toggle at the end of the dashboard and Kubernetes filter bars that opts into linked (faceted) filter values, off by default. When linked, each dropdown's values are narrowed by the other selections (and the K8s free-text search) and fetched lazily only when the dropdown is opened, bounding the cost of contingent value lookups that can't use per-key rollups. Search-page filters are untouched.
| const { data: sources, isLoading: isLoadingSources } = useSources(); | ||
|
|
||
| // Group filters by (source, metricType, where, whereLanguage) so that we can test each group for MV compatibility separately. | ||
| // Faceted filtering: each filter's selectable values are narrowed by the |
There was a problem hiding this comment.
One perf-related downside to this is that it makes it less likely that filters can leverage materialized views (since any selected filters being applied to the filter must be a dimension in the materialized view). Fine at reasonable scales, less so at scales that actually require MVs.
Maybe providing the option like we do on the search page is the right move, as Alex (I think?) suggested
| // single key-values query; each selected filter (which omits its own | ||
| // expression) splits into its own query. |
There was a problem hiding this comment.
Another potential idea, to reduce the number of queries / performance impact, could be to do what we do for source filters:
SELECT
groupUniqArrayIf(columnA, conditions on columnB),
groupUniqArrayIf(columnB, conditions on columnA)
FROM ...
There was a problem hiding this comment.
Also - there might be some additional code re-use opportunities now between dashboard filters and source filters.
Summary
Adds opt-in linked (faceted) filter values to the dashboard and Kubernetes filter bars. A bidirectional-arrow "link filters" toggle at the end of each bar (off by default) turns on filter-awareness: each dropdown then only shows values that co-occur with the other current selections — e.g. picking a
clusternarrows thenamespacedropdown to namespaces in that cluster (the K8s bar also factors in the free-text search). A filter never constrains its own options, so multi-select still works. When linked, a dropdown's narrowed values are fetched lazily only when it is opened, which bounds the cost of these contingent lookups — they can't be served from the cheap per-key rollups and are far more expensive at scale, so they stay opt-in and off by default. Search-page filters are intentionally untouched. Addresses HDX-4462.Screenshots or video
No screenshots: the local/preview demo dataset has no Kubernetes telemetry, so the K8s dropdowns are empty there. The narrowing was instead verified against live ClickHouse using the traces source — selecting
ServiceName = hdx-oss-dev-appnarrowed theSpanNamedropdown from 21 → 9 co-occurring values (and the reverse narrowedServiceNameto a single service).How to test on Vercel preview
Preview routes: /kubernetes
Steps:
/kubernetes.ClusterandNamespacedropdowns (cluster-filter-select,namespace-filter-select) and the link-filters toggle (k8s-filters-link-toggle).References