ajr
April 1, 2021, 10:48pm
1
How to update variables of a dashboard during provisioning?
I’m able to provision plugins, datasources with variables (jsonData), dashboardProviders and pre-load dashboards. But some of the dashboards need to populate a variable when importing. How we can do that?
ENV variables are not recognized.
Datasources allow you include the jsonData, which can easily scripted.
But dashboards does not have the jsonData option.
The documentation does not mention anything about that and cannot find examples on the internet.
habib1
April 4, 2021, 9:38pm
2
hello this is correct, it is basically not possible to do this. thanks
ajr
April 5, 2021, 3:29pm
3
No workarounds? Without that, provision of dashboards gets limited, as many needs variables.
ajr
April 5, 2021, 3:37pm
4
Would be great if supported something like this:
dashboards:
default:
test:
gnetId: 99999
revision: 1
datasource: SomeDatasource
jsonData:
VAR_REGION_DEPLOYMENT: us-west-1
k8s-cluster-metrics:
gnetId: 11663
revision: 1
datasource: Prometheus
1 Like
pooh
April 5, 2021, 3:46pm
5
I do this by creating the JSON file for a dashboard, modifying it (on whatever
machine knows what variables need changing), and then uploading to the Grafana
server, either by copying directly into /var/lib/grafana/dashboards/ or by
using the HTTP API.
Antony.
ajr
April 5, 2021, 4:07pm
6
Thanks. I was looking to make the Grafana provisioning more useful.
When deploying an app on Kubernetes using Terraform, having everything on the dashboards/datasource YAMLs would be perfect.
Using the HTTP API, which would need a script inside a k8s job, just to update one variable field seams a dirt workaround.
Cannot use Terraform Grafana provider either.
Hope that the option to provide values for variables using Grafana provision be at least on the roadmap
1 Like
habib1
April 5, 2021, 7:51pm
7
thank you please mark the question as answered
ajr
April 5, 2021, 8:21pm
8
The answer is that is not possible. Next step should be an Enhancement Request. How can we create that?
habib1
April 6, 2021, 3:02pm
10
yes you are right @mattabrams , and link to this threat
1 Like
glep207
January 17, 2022, 3:21pm
11
@ajr did you write up an enhancement request?
https://github.com/grafana/grafana/issues/10786#issuecomment-1521834164
AS-IS:
dashboards:
yorkie:
yorkie-dashboard:
gnetId: 18560
revision: 2
datasource: Prometheus
If you have multi vairables for dashboard.
TO-BE:
oci-oke:
gnetId: 13594
revision: 1
datasource:
- name: DS_OCI_METRICS
value: oci-metrics
- name: VAR_REGION_DEPLOYMENT
value: ap-singapore-1
- name: VAR_COMPARTMENT_ID
value: ocid1.tenancy.oc1..a...............