Reputation: 11
I've been trying to provision a dashboard on a Docker hosted Grafana server. My repository is set up as follows:
Docker
dashboard.JSON
{
"annotations": {
"list": \[
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "postgres"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
\]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1,
"links": \[\],
"panels": \[
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "postgres"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": \[\],
"thresholds": {
"mode": "absolute",
"steps": \[
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
\]
}
},
"overrides": \[\]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"fields": "",
"reducer": \[
"sum"
\],
"show": false
},
"showHeader": true
},
"pluginVersion": "10.4.2",
"targets": \[
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "postgres"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "select \* from retrievescripts()",
"refId": "A",
"sql": {
"columns": \[
{
"parameters": \[\],
"type": "function"
}
\],
"groupBy": \[
{
"property": {
"type": "string"
},
"type": "groupBy"
}
\],
"limit": 50
}
}
\],
"title": "Panel Title",
"type": "table"
}
\],
"schemaVersion": 39,
"tags": \[\],
"templating": {
"list": \[\]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "New dashboard",
"uid": "bdn9uavsiqi2oc",
"version": 1,
"weekStart": ""
}
dashboard.yaml
apiVersion: 1
providers:
# \<string\> an unique provider name. Required
- name: 'a unique provider name'
# \<int\> Org id. Default to 1
orgId: 1
# \<string\> name of the dashboard folder.
folder: ''
# \<string\> folder UID. will be automatically generated if not specified
folderUid: ''
# \<string\> provider type. Default to 'file'
type: file
# \<bool\> disable dashboard deletion
disableDeletion: false
# \<int\> how often Grafana will scan for changed dashboards
updateIntervalSeconds: 10
# \<bool\> allow updating provisioned dashboards from the UI
allowUiUpdates: false
options:
# \<string, required\> path to dashboard files on disk. Required when using the 'file' type
path: /var/lib/grafana/dashboards
# \<bool\> use folder names from filesystem to create folders in Grafana
foldersFromFilesStructure: true
docker-compose.yaml
grafana-service:
image: grafana/grafana:latest
container_name: grafana-container
ports:
- "23000:3000"
volumes:
- ./dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
- ./datasources.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./dashboards:/var/lib/grafana/dashboards
The problem is that the datasource provisioning works fine. but when trying to provision a dashboard nothing seems to happen. noting special in the docker logs.
The main purpose of this project is to automatically create the dashboard and datasource when creating or rebuilding the docker container.
Upvotes: 1
Views: 299
Reputation: 11
For anyone experiencing the same problem. apparently it's very important to use .json instead of .JSON.
This fixed the entire issue for me
Upvotes: 0