I know it wasn’t mentioned in the Grafana 13.2 release notes, but I noticed that there were new features added behind the globalDashboardVariables feature flag, which allows to define dashboard variables on global / folder scope. That’s nicely described in this PR.
Unfortunately, setting the toggle didn’t show me the menu item Dashboards > Variables.
Can anyone guide me to how it can be used already in the early stage? It’s for us a super helpful feature, as we want to evaluate Git Sync and avoid Terraform templating during dashboard provisioning..
I noticed that a few weeks later, an OpenFeature-based toggle has been added:
Just not sure how to specify those. I tried the following Helm chart values config, but this resulted in Settings UI showing map[dashboardGlobalVariables:true]:
Was Grafana restarted properly?
Do you work with V2 dashboards (dashboard schema v2)?
LLM advice:
Once enabled:
Dashboards → Variables nav item appears under the Dashboards section (for org-wide variable management at /dashboards/variables).
Global and folder-scoped variables defined via dashboard.grafana.app/v2beta1 are automatically injected into every V2 dashboard at load time.
A “Predefined variables” option appears in the dashboard sidebar to control which global/folder variables a dashboard inherits (None, All, or specific ones).
It is still experimental:
So I would say you (your AI agent) need to read source code to find how it works.
Global dashboard variables were an experimental feature until 13.3, that’s why they were not mentioned in 13.2 release notes. And sorry about the confusion with the feature flag! We switched to OpenFeature and had to rename the flag.
We’ve been playing around with the feature and discussed, how it would finally allow us to switch to Git Sync (as we currently have Terraform to parametrize dashboards for our different Grafana deployments).
Not sure if it’s exactly what you said with “don’t have support for git sync yet”, but we also noticed the shortcomings of
every dashboard needs to be changed to make use of variables
setting is not in the dashboard schema
Will it be long-term the case that one doesn’t have to change every dashboard to incorporate global variables? Or should I open an issue for that?
I meant we currently don’t support managing global variables in Git Sync, but if there’s interest, we could implement that.
every dashboard needs to be changed to make use of variables
This is expected because creating a global variable would make it show in every dashboard in a Grafana instance (even on dashboards where a global variable doesn’t apply), which would be disruptive, especially for instances with 1000s of dashboards. On top of that, every time a user creates a new global variable, that variable would again show up in all dashboards, and users would have to opt out specifically.
Setting is not in the dashboard schema
This is also expected because we reference these variables by name in the Dashboard resource’s metadata.annotations.grafana.app/useCrossDashboardVariables. Apologies for not including an example of how to reference it in my previous reply. Here it is:
resource "grafana_apps_generic_resource" "demo_dashboard" {
manifest = {
apiVersion = "dashboard.grafana.app/v2"
kind = "Dashboard"
metadata = {
name = "tf-cross-dash-vars-demo"
annotations = {
"grafana.app/folder" = grafana_folder.shared.uid
# JSON string. "all" auto-includes new vars in that scope; a name list does not.
"grafana.app/useCrossDashboardVariables" = jsonencode({
global = ["env", "region"]
folder = ["cluster"]
})
}
}
spec = {
title = "Cross-dashboard variables demo"
cursorSync = "Off"
preload = false
elements = {}
layout = { kind = "GridLayout", spec = { items = [] } }
timeSettings = {
timezone = "browser"
from = "now-6h"
to = "now"
}
}
}
}
I hope this helps, feel free to reach out with any additional questions.
Thanks for your response. Let me explain our use case / idea how we replace Terraform for dashboard provisioning with Git Sync. Using TF is cumbersome, as we have to export dashboard JSON and escape all `${` so that TF doesn’t try to substitute Grafana variables. Git Sync looks soo much better.
We work with multiple Grafana deployments, all showing the same dashboards across isolated deployments (of production systems AND separate Grafanas). Imagine those would be for a hand full of customers. So we have a TF variable `${customer}` in the dashboard JSON, which is replaced by Terraform with `customer-a`. This value is then often used to construct identifiers in AWS or query based on Prometheus labels `customer=“${customer}”`.
If we now switch to Git Sync, we would still need some way to have parametrization of `$customer`, with Grafana-deployment specific value. We thought that a global variable would be perfect for this so that no longer TF replaces it, but Grafana.
I understand that having variables shown for every dashboard - in our case we would use hidden variables. Would it then make sense for you to be able to declare the variable as to be used across all dashboards? I think there was no way to create a dashboard with a reference to global variables, share it via Git Sync, and then just use it in the other Grafana deployments. That setting was not carried over (as you describe).
I hope my description now makes more sense to you.
Thank you for clarifying this. That use case makes sense, and just to make sure, this is how I understand it. The dashboards stay identical, and the only thing that changes per Grafana is the value of $customer, which Terraform substitutes today before the JSON is loaded. A hidden global variable is the right replacement for that. Git Sync holds the dashboards, the value of $customer stays on each Grafana.
I think there was no way to create a dashboard with a reference to global variables, share it via Git Sync, and then just use it in the other Grafana deployments.
There’s a way to do this, full Dashboard resource can carry it, so you would do something like this for Git Sync:
{
"apiVersion": "dashboard.grafana.app/v2",
"kind": "Dashboard",
"metadata": {
"name": "overview",
"annotations": {
"grafana.app/useCrossDashboardVariables": "{\"global\":[\"customer\"]}"
}
},
"spec": { the actual dashboard content - what is in the schema }
}
Are your dashboards written in the v2 schema or the old schema?