Skip to content

Conversation

@Develer
Copy link
Contributor

@Develer Develer commented Aug 26, 2025

What is this feature?

This PR adds a toggle that allows the user to enable/disable adhoc filters for that specific Dashboards DS. If the toggle is disabled, Dashbboard DS ad hoc filters in the dashboard should have no effect on the panel.

image

Which issue(s) does this PR fix?:

Fixes #109902

Special notes for your reviewer:
You need to enable the dashboardDsAdHocFiltering feature flag in order to test this.

Here is a dashboard for testing:
adhoc toggle test-1756220242419.json

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@Develer Develer self-assigned this Aug 26, 2025
@Develer Develer requested a review from a team as a code owner August 26, 2025 12:24
@Develer Develer requested a review from grafanabot as a code owner August 26, 2025 12:24
@Develer Develer added the no-backport Skip backport of PR label Aug 26, 2025
@Develer Develer requested review from Sergej-Vlasov and oscarkilhed and removed request for a team August 26, 2025 12:24
@Develer Develer added no-changelog Skip including change in changelog/release notes team/grafana-datapro labels Aug 26, 2025
@github-actions github-actions bot added this to the 12.2.x milestone Aug 26, 2025
@Develer Develer requested review from a team, gelicia and samjewell and removed request for a team, Sergej-Vlasov and oscarkilhed August 26, 2025 12:25
@natellium
Copy link
Contributor

Seems to work as expected! Here's dashboard JSON to make it easier to check

{ "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": 5, "links": [], "panels": [ { "datasource": { "type": "grafana-testdata-datasource", "uid": "bel243skzm3uoa" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": 0 }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 7, "w": 24, "x": 0, "y": 0 }, "id": 1, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "12.2.0-pre", "targets": [ { "csvContent": "user_id,name,email,signup_date,age,gender\n1,Alice,alice@email.com,2025-01-15,28,F\n2,Bob,bob@email.com,2025-02-20,35,M\n3,Charlie,charlie@email.com,2025-03-05,42,M\n4,Diana,diana@email.com,2025-04-12,30,F\n5,Eve,eve@email.com,2025-05-01,25,F\n6,Frank,frank@email.com,2025-05-15,33,M\n7,Grace,grace@email.com,2025-06-01,27,F\n8,Henry,henry@email.com,2025-06-10,39,M\n9,Ivy,ivy@email.com,2025-06-20,31,F\n10,Jack,jack@email.com,2025-07-01,26,M\n11,Kate,kate@email.com,2025-07-15,29,F\n12,Leo,leo@email.com,2025-07-30,37,M", "datasource": { "type": "grafana-testdata-datasource", "uid": "bel243skzm3uoa" }, "refId": "A", "scenarioId": "csv_content" } ], "title": "Source panel", "type": "table" }, { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": 0 }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 0, "y": 7 }, "id": 2, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "12.2.0-pre", "targets": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "panelId": 1, "refId": "A", "useAdHocFilters": true } ], "title": "Should filter panel", "type": "table" }, { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": 0 }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 7 }, "id": 3, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "12.2.0-pre", "targets": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "panelId": 1, "refId": "A", "useAdHocFilters": true } ], "title": "Should filter panel", "type": "table" }, { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": 0 }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, "x": 12, "y": 15 }, "id": 4, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "12.2.0-pre", "targets": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "panelId": 1, "refId": "A", "useAdHocFilters": true } ], "title": "Should not filter panel", "type": "table" } ], "preload": false, "schemaVersion": 41, "tags": [], "templating": { "list": [ { "baseFilters": [], "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "filters": [ { "key": "name", "nonApplicable": false, "operator": "!=", "value": "Bob" }, { "key": "name", "operator": "!=", "value": "Alice" } ], "name": "query0", "type": "adhoc" } ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": {}, "timezone": "browser", "title": "New dashboard", "uid": "8e07dedb-13c5-45b7-a0e9-77bfb54ca292", "version": 6 }

@Develer Develer added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Aug 27, 2025
Copy link
Contributor

@gelicia gelicia left a comment

Choose a reason for hiding this comment

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

The test dashboard provided in the issue PR description includes two panels with no obvious differentiation and one panel that is labeled to not be filtered, but the toggle is on, and it is filtered. Please double check testing dashboards to be sure they are straightforward and accurate to facilitate easier testing. Additionally, if your PR requires a feature flag to work, please include that information in the description. I edited your description to include it for future reference.

Other than that, the code looks good and functions well!

Copy link
Contributor

@alexjonspencer1 alexjonspencer1 left a comment

Choose a reason for hiding this comment

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

@alexjonspencer1
Copy link
Contributor

@Develer Let me know if anything material changes after you resolve the datasource.test.ts and I can re-check. If it's immaterial, feel free to merge!

@Develer Develer enabled auto-merge (squash) September 3, 2025 12:28
@Develer Develer merged commit 1faaec2 into main Sep 3, 2025
102 of 103 checks passed
@Develer Develer deleted the 109902-add-p2p-filter-toggle branch September 3, 2025 12:51
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.

Add option to enable ad hoc filters for the Dashboards DS on a panel level

5 participants