Reputation: 33861
I've got a new datasource I would like an existing dashboard to use.
How can I change it over? Is there a quicker way than exporting / importing the dashboard?
Upvotes: 31
Views: 42929
Reputation: 1
For anyone looking for a quick win, here is what worked for me when I wanted to go from a datasource to another one with the same type (In my case InfluxDB) :
Upvotes: 0
Reputation: 1027
open json model, find templating.list section. add following part
"templating": {
"list": [
{
"label": "Data source",
"name": "DS_PROMETHEUS",
"query": "prometheus",
"type": "datasource"
},
...
It helped me to fix most of broken dashboards. Be sure if datasource objects defined in such form
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
Upvotes: 0
Reputation: 123
Add __inputs
block at the root of JSON file
{
"__inputs": [
{
"name": "DS_PROMETHEUS_ID",
"label": "Prometheus Data Source",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
...
description: "",
panels:[...]
...
}
then replace all static uid
values with ${DS_PROMETHEUS_ID}
Now while importing the dashboard you will get the option to choose your own data source.
Upvotes: 6
Reputation: 101
In the JSON Model (dashboard settings), you can just replace all the occurrence of the id of the old source by the id of your new one
Upvotes: 0
Reputation: 2387
The following trick worked for me with Grafana 8.
As preparation you have to create a datasource variable "DS_PROMETHEUS".
Then inside the dashboard:
Then in the same dashboard open the "Dashboard settings"->"JSON Model" and paste the json from above.
Upvotes: 3
Reputation: 1530
Specifying a variable would not solve all the problems with changing a data source for the existing dashboard - there will be still some metadata pointing to the old one, which will result in failures. The only thing that worked for me was to go to dashboard setting and copy aside the JSON model, careful find+replace and pasting back the model. I know it's pretty lame, but this was the only thing that worked. There seems to be something missing with this feature in Grafana at the moment...
Upvotes: 12
Reputation: 28132
You can specify data source variable for a dashboard:
http://docs.grafana.org/reference/templating/#variable-types
Upvotes: 1