Skip to content

Filtering: NonApplicability improvements#1373

Draft
mdvictor wants to merge 16 commits intomainfrom
mdv/non-applicable-filters-prometheus
Draft

Filtering: NonApplicability improvements#1373
mdvictor wants to merge 16 commits intomainfrom
mdv/non-applicable-filters-prometheus

Conversation

@mdvictor
Copy link
Collaborator

@mdvictor mdvictor commented Feb 26, 2026

📦 Published PR as canary version: 7.2.0--canary.1373.22762235062.0

✨ Test out this PR locally via:

npm install @grafana/scenes@7.2.0--canary.1373.22762235062.0
npm install @grafana/scenes-react@7.2.0--canary.1373.22762235062.0
# or 
yarn add @grafana/scenes@7.2.0--canary.1373.22762235062.0
yarn add @grafana/scenes-react@7.2.0--canary.1373.22762235062.0

@mdvictor mdvictor changed the title Mdv/non applicable filters prometheus Filtering: NonApplicability improvements Feb 26, 2026
const originFilters = this.state.originFilters?.filter((f) => f.key !== filter.key && !f.nonApplicable) ?? [];
const otherFilters = this.state.filters
.filter((f) => f.key !== filter.key && !f.nonApplicable)
.concat(originFilters);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need to check in values too for non applicability, otherwise if we have some nonapplicable filters and search for values, nothing will come up because of that nonexistent label being set on the query

* order, so duplicates with the same key+origin are matched positionally within
* their group rather than relying on global array ordering.
*/
export function buildApplicabilityMatcher(response: DrilldownsApplicability[]) {
Copy link
Collaborator Author

@mdvictor mdvictor Mar 3, 2026

Choose a reason for hiding this comment

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

I've been looking into a different way of more safely handling the returned applicability results. The API will return an array with the filter data and whether they are applicable or not, but there is nothing enforcing the backend to return the array in the same order as it was received. We used a map before with the assumption that there will be no 2 filters with the same key or origin which is what the map key was formed from.

I am experimenting with this map of queues which would better preserve two filters with the same key and no origin, for example, but would still depend on the ds returning the relative order of these 2 filters for example. PromDS would return the relative order properly, but there is no way to enforce it, this needs to be intentional.

With just a simple map we'd just lose one key along the way...

@mdvictor mdvictor added minor Increment the minor version when merged release Create a release when this pr is merged labels Mar 3, 2026
const filtersApplicabilityEnabled = this._adhocFiltersVar?.state.applicabilityEnabled;
const groupByApplicabilityEnabled = this._groupByVar?.state.applicabilityEnabled;

if (!filtersApplicabilityEnabled && !groupByApplicabilityEnabled) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is basically the grafana FF check

@mdvictor mdvictor requested a review from dprokop March 5, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged release Create a release when this pr is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant