From ab8ce6398c21e6283f58a13c0f977b72da308680 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 24 Jan 2026 13:35:38 +0000 Subject: [PATCH] Fix Grafana app variable not populating on dashboard load - Change refresh from 2 (on time range change) to 1 (on dashboard load) so the $app variable query runs when the dashboard first opens - Add 'current: {}' field to properly track selected value state - Add 'options: []' field for Grafana to store fetched options - Add 'sort: 1' for alphabetical ascending sort of app values This fixes the issue where the $app dropdown was blank when opening the generated dashboard. Co-authored-by: r.buddie --- Gemfile.lock | 2 +- lib/diffdash/outputs/grafana.rb | 7 +++++-- spec/fixtures/grafana/dashboard_v1_fixture.json | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a346f97..a907496 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - diffdash (0.1.11) + diffdash (0.1.14) ast (~> 2.4) dotenv (>= 2.8) faraday (>= 2.0) diff --git a/lib/diffdash/outputs/grafana.rb b/lib/diffdash/outputs/grafana.rb index a651ff4..ef1dc10 100644 --- a/lib/diffdash/outputs/grafana.rb +++ b/lib/diffdash/outputs/grafana.rb @@ -101,9 +101,12 @@ def app_variable type: "query", datasource: { type: "loki", uid: "${datasource_loki}" }, query: "label_values({app!=\"\"}, app)", - refresh: 2, + refresh: 1, includeAll: false, - multi: false + multi: false, + current: {}, + options: [], + sort: 1 } end diff --git a/spec/fixtures/grafana/dashboard_v1_fixture.json b/spec/fixtures/grafana/dashboard_v1_fixture.json index ed6d058..46397c7 100644 --- a/spec/fixtures/grafana/dashboard_v1_fixture.json +++ b/spec/fixtures/grafana/dashboard_v1_fixture.json @@ -50,9 +50,12 @@ "uid": "${datasource_loki}" }, "query": "label_values({app!=\"\"}, app)", - "refresh": 2, + "refresh": 1, "includeAll": false, - "multi": false + "multi": false, + "current": {}, + "options": [], + "sort": 1 } ] },