helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

How to set dashboards using dashboard id from grafana website.

Open kaykhancheckpoint opened this issue 2 years ago • 8 comments

I want to have a grafana dashboard imported by default when i deploy grafana. The dashboard i am looking for is - https://grafana.com/grafana/dashboards/7353 i can import this via the following ID 7353

Is there a way i can specify this ID in my chart setup for grafana?

grafana:
  persistence:
    type: pvc
    enabled: true 
    storageClassName: general 
    accessModes:
      - ReadWriteOnce
    size: 25Gi 
    finalizers:
      - kubernetes.io/pvc-protection
  nodeSelector:
    acme/node-type: ops
  adminPassword: <removed>
  service:
    type: NodePort

I can see in the documentation there are a number of fields relating dashboards dashboardProviders etc, but im not quite sure how i use these fields to get what i want.

kaykhancheckpoint avatar May 18 '22 07:05 kaykhancheckpoint

I do not have experience with that specific topic. The easy workaround would be to download it as json. But there are options in the chart to download dashboard. You might want to try these or use the options in the sidecar section of the chart.

Atom7k-4 avatar May 18 '22 08:05 Atom7k-4

Can you point me to the option you are refering in the sidecar?

kaykhancheckpoint avatar May 18 '22 08:05 kaykhancheckpoint

If you installed Grafana using the helm chart, you should be able to provision the dashboards during install, by including it under dashboardproviders and dashboards in your values like you mentioned yourself.

If you have not solved this yet, let me know and I can write up some example for you.

deggja avatar Jun 06 '22 22:06 deggja

@deggja please provide an example I found this issue because I'm looking how to do it myself. I'm especially wondering how dashboardProviders supposed to look like as I'm not importing it from local filesystem like the given example.

takeda avatar Jun 07 '22 06:06 takeda

@takeda You should be able to provision the dashboard by including this in your values:

  dashboardproviders.yaml:
    apiVersion: 1
    providers:
    - name: 'default'
      orgId: 1
      folder: 'default'
      type: file
      disableDeletion: true
      editable: true
      options:
        path: /var/lib/grafana/dashboards/standard
dashboards:
  default:
    imported-dashboard-name:
      gnetId: 7353
      datasource: yourdatasource

deggja avatar Jun 07 '22 06:06 deggja

Thanks, will try that.

BTW so type still has to be file and the path needs to be provided? Those two things were confusing me the most.

takeda avatar Jun 07 '22 08:06 takeda

Thanks, will try that.

BTW so type still has to be file and the path needs to be provided? Those two things were confusing me the most.

Yes, I believe so. But you can play around with removing it and see what happens if you like. The configuration above is what I used in my last project, so it does at least work :-)

deggja avatar Jun 07 '22 08:06 deggja

Dear @takeda, @deggja Could you kindly help me understanding why I cannot see my imported dashboard after deploying my helm chart?

It seems it downloads it correctly as I see it inside the POD but it's not later imported on Grafana:

grafana-bf964df7c-n56ch:~$ ls /var/lib/grafana/dashboards/default
jvm-micrometer.json

Here is my chart values:

datasources.yaml:
  apiVersion: 1
  datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server

dashboardproviders.yaml:
  apiVersion: 1
  providers:
    - name: 'default'
      orgId: 1
      folder: 'default'
      type: file
      disableDeletion: true
      editable: true
      options:
        path: /var/lib/grafana/dashboards/default

dashboards:
  default:
    jvm-micrometer:
      gnetId: 4701
      revision: 10
      datasource: Prometheus

Thanks a lot

danparisi avatar Feb 23 '24 15:02 danparisi

@danparisi The dashboardproviders.yaml block must be nested under dashboardProviders: https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml#L702

Similar for datasources.yaml: https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml#L593

kjaleshire avatar Apr 11 '24 18:04 kjaleshire