Reputation: 8960
Is it possible to import a dashboard when building my docker image for Grafana.
My docker-compose.yml
currently looks like this:
# /docker-compose.yml
version: "3"
services:
grafana:
image: grafana/grafana:latest
ports:
- 3000:3000
Is there anything I can add there - btw the dashboard I would like to have pre setup is: https://grafana.com/grafana/dashboards/10562
Thanks.
Upvotes: 20
Views: 21544
Reputation: 7307
I'm using this to automatically import a dashboard to visualise my k6 load test runs:
docker-compose.yml
:
services:
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- ./grafana/dashboard.yaml:/etc/grafana/provisioning/dashboards/main.yaml
- ./grafana/dashboards:/var/lib/grafana/dashboards
grafana/dashboard.yaml
:
apiVersion: 1
providers:
- name: "Dashboard provider"
orgId: 1
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true
grafana/dashboards/main-dashboard.json
:
{
"title": "Main Dashboard",
"description": "A dashboard..."
...
}
Upvotes: 30
Reputation: 2376
Provisioning a dashboard just by adding something to your YML is not possible. The way to achieve this is not that straight-forward.
Provisioning a dashboard in Grafana is generally supported and widely used. You can find the official doc here. The gist of it is that you have to use provide provisioning YMLs to grafana. In these config files you have to point to dashboard files in JSON format. You cannot point to a dashboard in the Grafana Cloud.
Therefore you will have to download the dashboard beforehand and store it. Alternatively you can of course fetch the dashboard every time you run your pipeline that deploys Grafana.
So in short, the simplest option for you:
Upvotes: 2