/grafana-loader

Syncs Grafana dashboards from Kubernetes ConfigMaps

Primary LanguageGo

grafana-loader CircleCI DockerHub

Syncs Grafana v5+ dashboard definitions from Kubernetes ConfigMaps.

Usage

To deploy, ensure the following file is added to Grafana's dashboard provisioning directory (/etc/grafana/provisioning/dashboards by default):

apiVersion: 1

providers:
- name: 'default'
  orgId: 1
  folder: ''
  type: file
  disableDeletion: true
  options:
    path: /tmp/dashboards

Then run grafana-loader as a sidecar in the Grafana pod:

apiVersion: apps/v1
kind: Deployment
metadata:
  # ...
spec:
  # ...
  template:
    spec:
      containers:
      - name: grafana
      	# ...
        volumeMounts:
        - name: dashboards
          mountPath: /tmp/dashboards
      - name: dashboard-loader
        image: "carlpett/dashboard-loader:v0.0.1"
        imagePullPolicy: IfNotPresent
        ports:
        - name: metrics
          containerPort: 8080
          protocol: TCP
        securityContext:
          runAsUser: 1000
          fsGroup: 1000
        resources:
          requests:
            cpu: 10m
            memory: 10Mi
        volumeMounts:
          - name: dashboards
            mountPath: /tmp/dashboards
      volumes:
      - name: dashboards
        emptyDir: {}

This will keep all ConfigMaps labeled grafana-dashboard=true synced in the /tmp/dashboards directory.

Advanced usages

Download the latest release, pull the Docker image or follow the instructions below for building the source.

There is a --help flag for listing the available flags.

Building from source

go get -u github.com/carlpett/grafana-loader and then make build.