Persisting Grafana dashboards¶
This guide will tell you how to persist dashboards to survive upgrades and migrations to new instances of Grafana.
Overview of the task¶
- Create a
GrafanaDashboardkind file in the /gitops folder - Get the JSON that forms the board
- Add the JSON
- Escape double curlies
- Make a PR
1. Create a GrafanaDashboard kind file¶
- Create a YAML file in gitops/dplplat02/grafana/template
- Add the the following YAML to the file
apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaDashboard metadata: name: name-of-the-board spec: resyncPeriod: 30s instanceSelector: matchLabels: dashboards: "grafana" <--- do not change this! json: >
2. Get the JSON that forms the board¶
- Go to the board you want to persist
- Press the 'export' button, and select 'as code' option
- Copy the full JSON body
3. Add the JSON¶
- Go the
GrafanaDashboardfile - Put the cursor underneath the
json: >and paste the JSON contents. Make sure to indent it properly.
4. Escape the double curlies¶
The double curlies, holding variables, needs to be escaped. Otherwise Argo can't deploy the dashboard. This is done by replacing {{ someVar }} with {{ "{{someVar}}" }}.
5. Make a PR¶
Sent a PR. This step matters because the operations team needs to ensure the deployment of the Dashboard.