Docker provisioned dashboard not showing up

Hello,

I’m trying to add a dashboard through provisioning. I have a single dashboard.json in /var/lib/grafana/dashboards and a YAML config file in /etc/grafana/provisioning/dashboards that looks like this:

# # config file version
apiVersion: 1

providers:
  - name: 'default'
  orgId: 1
  folder: ''
  type: file
  updateIntervalSeconds: 3 #how often Grafana will scan for changed dashboards
  options:
    path: /var/lib/grafana/dashboards 

However, the dashboard doesn’t show up, even after multiple restarts. I’ve checked the logs, but didn’t see anything regarding this. I was successfully able to add a datasource through provisioning in much the same way, so I’m not sure what could be wrong. Any ideas what could be wrong?

Thanks!

hi! does anyone have an example of docker compose for dashboard provisiong? I’m having the same issue as above, having configured a yaml config and having a .json definition for my dashboard, but it is not being picked up.

thanks in advance!
Sonja

EDIT: I have found a solution, based on that answer: Grafana provisioning dashboards in Docker - Super User

Hi @youn98,

Thanks for opening this post.

There are some certain steps to provision a dashboard into the Grafana while using Docker (docker-compose v3).

I also played around with it today and it seems to be working for me so I will try to explain it step by step and it should work for you (maybe you need v.small modification in adjusting your path etc.)

Step 1

While using the Docker image, there are some default config paths as defined here. For us the important ones are;

Setting Default value
GF_PATHS_DATA /var/lib/grafana
GF_PATHS_PROVISIONING /etc/grafana/provisioning

Step 2

Create a directory let’s say my-grafana-dashboard and inside it, define the following files and folders (here is my tree command output);

[root@docker my-grafana-dashboard]# tree

├── docker-compose.yml
└── provisioning
    ├── dashboards
    │   ├── default.yml
    │   └── my-dashboard.json
    └── datasources

Step 3

For the file my-dashboard.json put the JSON data of the dashboard. For e.g., I put a telegraf dashboard data after downloading the JSON from this link (you can put any other or your own working one).

Step 4

As per documentation we need to create a file inside the provisioning directory as default.yml and there put the most minimal required data. In my case I put as per documentation i.e.;

apiVersion: 1

providers:
  # <string> an unique provider name. Required
  - name: 'TEST TELEGRAF Provising test'
    # <int> Org id. Default to 1
    orgId: 1
    # <string> name of the dashboard folder.
    folder: 'Service'
    # <string> folder UID. will be automatically generated if not specified
    folderUid: ''
    # <string> provider type. Default to 'file'
    type: file
    # <int> how often Grafana will scan for changed dashboards
    updateIntervalSeconds: 10
    # <bool> allow updating provisioned dashboards from the UI
    # allowUiUpdates: false #you can set this value as per your need
    options:
      # <string, required> path to dashboard files on disk. Required when using the 'file' type
      # though as per the documentation it says that the path for Linux is /var/lib/grafana 
      # but in docker (see step 1) it is like this.
      path: /etc/grafana/provisioning/dashboards

You can find the complete details here but for us, this minimum config is fine to make a test.

Step 5

Now define the following code in the docker-compose.yml file

version: "3"
services:
  grafana:
    image: grafana/grafana-oss:9.1.0
    container_name: grafana
    # if you are running as root then set it to 0 else find the right id with the id command
    user: "0"
    volumes:
    # defining our main config parameters for provisioning if we have datasource
    # commented it out as for now we do not need it
    # - ./provisioning/datasources:/etc/grafana/provisioning/datasources/
   # defining our main config parameters for provisioning for dashboards
    - ./provisioning/dashboards:/etc/grafana/provisioning/dashboards/
    ports:
      - "3000:3000"
    restart: unless-stopped

Step 6

Finally, run the command

[root@docker my-grafana-dashboard]# docker-compose up -d

Wait for 10 seconds and then you should see the dashboard

If you run into any problems, then check the logs via command:

[root@docker my-grafana-dashboard]# docker-compose logs grafana

Hi @sonja,

You can follow up on the steps I wrote as it also links to the official documentation for references.

I hope this helps.