Dear all,
We are deploying a new platform under the thought that everything should be deployed and operated as code, and i have been working on the Grafana part. Automating the installation and setting up datasources went very smooth, but i’m having a hard time in updating a dashboard after initial deployment.
We have our dashboard JSON-definitions sitting in a git-repo, and in these definitions the UID and ID equals null. So the http_api will create the dashboards and threat them as new ones. So far so good.
However, let’s now assume I want to update existing dashboards. E.g. I update a version from version 1 to 2, I now want to deploy this over multiple clusters. I don’t see how I can achieve this. Below are the methods that i’ve tried:
Method 1: Deleting dashboards
One approach would be to delete the current dashboard, and deploy the updated dashboard again. However when I want to delete the dashboard I don’t know the UID of the exact dashboard. So i’d have to manually look and update my scripts each time I want to do this.
I can’t define an UID or ID in the .json files of the GIT, because if I do this, a deployment will fail if the dashboards are not present.
Method 2: Updating dashboards
I know I can update a dashboard, but again, I don’t know the UID of a dashboard and there’s no easy way to obtain an API based on a name.
Method 3: Ignoring old dashboards
An alternative approach would be to ignore old dashboards, just deploy a newer one, and leave the old ones where they are. I would just keep deploying dashboards with a UID and ID of null.
The few resources wasted in doing this approach is something I can live with. However, I found out that not only the UID and ID need to be unique but the name too.
E.g. This means that if I have a dashboard called ‘Infrastructure metrics’ with uid ‘abcdef123’, I can not add a dashboard called ‘infrastructure metrics’ with uid null. I could hardcode a timestamp in the dashboard titles, but not a pretty approach either.
Method 4: Using deprecated slug"
The only reliable way I found to manage dashboards is to fall back to the good ol’ slug. I can hardcode a slug in a dashboard, and use the slug value to update the dashboard.
However I am not very comfortable in doing this as using a ‘slug’ is a deprecated feature which will eventually be removed.
Looking at all what i’ve tried above I am running out of ideas. Am I doing something completely wrong or overlooking something simple? I’d like to know how the community manages updating their dashboards.