Grafana replaces datasources from older imported dashboards with the default datasource

… potentially rewriting the dashboard json code in sometimes unexpected and unwanted ways.

When importing some old dashboard that used “null” as datasource, newer instances of Grafana do replace this with the default datasource. In my case, where datasources such as Graphite and Prometheus are mixed, this can be very annoying when importing a dashboard that was made for Prometheus.

One solution can be to bulk-change the occurrences of

"datasource": null

with sed:

sed -i 's/"datasource": null/"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}/g' dashboard.json

This declares the datasource to be a variable datasource to be chosen by a custom annotation.

It also prevents Grafana from removing correct Prometheus queries for panels, which it does, if it things that the datasource is a Graphite datasource.

Kommentare

Leave a Reply

Your email address will not be published. Required fields are marked *