How to parametrize dashboard in Grafana
How to use $DS_PROMETHEUS and don’t get error ‘not found’
Published in
1 min readJul 15, 2023
The problem I’ve just solved was to use $DS_PROMETHEUS
as datasource for a provisioned dashboard.
I’ve looked at node-exporter, thought a bit and found solution.
You need two additional sections in your dashboard json file:
__inputs
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
templating
You need to add this piece into templating.list (e.g. after “list”, into … well, the list.
"templating": {
"list": [
{
"current": {
"selected": false,
"text": "default",
"value": "default"
},
"hide": 0,
"includeAll": false,
"label": "datasource",
"multi": false,
"name": "DS_PROMETHEUS",
"options": [],
"query": "prometheus",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
(I’m showing it with templating.list
part to help to find where to put it).
You also need to replace all datasources to this:
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
But if you found this article, you already know about it.