Dileeka Fernando
Dileeka Fernando

Reputation: 211

How to Deploy Grafana dashboard with side car and group the dashboard with specific dashboards Folder

Could you please let me know, How should I deploy a grafana dashboard with sidecar and place/group it in specific dashboard folder?

Example ( Mongo DB dashboard resides in Mongo Folder and Postgres at Postgres Folder). Please note that I am NOT talking about file locations ( /tmp/dashboards ).

I am using the grafana stable HELM chart and latest version of grafana (version 6.4.2)

I am deploying JSON dashboards with k8s configmap and label the config map with sidecar dashboard label. Once deployed it always goes to default "General" dashboards Folder.

HRLM values

  sidecar:
    dashboards:
      enabled: true
      label: grafana_dashboard

THANKS

Upvotes: 3

Views: 8635

Answers (2)

C4K3
C4K3

Reputation: 1

You can enable foldersFromFilesStructure to have grafana organize the dashboards in grafana based on the directories in the filesystem

Combined with the folderAnnotation option to make the sidecar place the dashboard files into a given subdirectory (in the filesystem) based on a Kubernetes annotation on the ConfigMap will result in the dashboards being put into the correct folder in grafana.

Your helm values should look something like

sidecar:
  dashboards:
    enabled: true
    label: grafana_dashboard
    folderAnnotation: "folder" # Can be set to anything you want
    provider:
      foldersFromFilesStructure: true

Then in your ConfigMaps you would add the folder annotation:

kind: ConfigMap
metadata:
  labels:
    grafana_dashboard: "1"
  annotations:
    folder: "Postgres"

Upvotes: 0

touati ahmed
touati ahmed

Reputation: 401

You can add dashboard Providers to your values file and specify custom configurations for each of your folders.

You can check the default values for Grafana chart to find an example.

The dashboardProviders should be under grafana, same indentions as sidecar.

Example :

grafana:
  dashboardProviders:
    dashboardproviders.yaml:
      apiVersion: 1
      providers:
      - name: folder1
        orgId: 1
        type: file
        folder: folder1
        allowUiUpdates: true
        disableDeletion: false
        updateIntervalSeconds: 10
        editable: true
        options:
          path: /tmp/dashboards/folder1
      - name: folder2
        orgId: 1
        type: file
        folder: folder2
        allowUiUpdates: true
        disableDeletion: false
        updateIntervalSeconds: 10
        editable: true
        options:
          path: /tmp/dashboards/folder2
      - name: folder3
        orgId: 1
        type: file
        folder: folder3
        allowUiUpdates: true
        disableDeletion: false
        updateIntervalSeconds: 10
        editable: true
        options:
          path: /tmp/dashboards/folder3

Then you can add an annotation to each of your dashboards configmaps to tell helm chart where to place those dashboards :

apiVersion: v1
kind: ConfigMap
metadata:
  name: name-of-dashboard
  labels:
    grafana_dashboard: "1" #
  annotations:
    k8s-sidecar-target-directory: /tmp/dashboards/folder1

This annotation will tell helm to place the target dashboards under /tmp/dashboards/folder1 so that they can be managed by folder1 provider.

Upvotes: 7

Related Questions