grafana-watcher

command
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

README

Grafana Watcher

The Grafaner Watcher was built for the kube-prometheus collection in order to run Grafana in an easily replicable manner without the need to run a complicated database, and rather provision dashboards from configs off of files. It subscribes to filesystem changes in a given directory, reads files matching *-datasource.json and *-dashboard.json and imports the datasources and dashboards to a given Grafana instance via Grafana's REST API.

How to use

A Docker container is provided on quay.io/coreos/grafana-watcher or can be built by your self. Run the container and make sure Grafana is reachable from Grafana Watcher. Pass source directory and Grafana URL to start command, e.g:

When running on Kubernetes, make sure to mount a volume containing the desired dashboards and datasources to watch-dir, e.g. as ConfigMap, as showed below. Minimal Kubernetes example configuration:

deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: grafana
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: grafana
    spec:
      containers:
      - name: grafana
        image: grafana/grafana:4.4.3
      - name: grafana-watcher
        image: quay.io/coreos/grafana-watcher:v0.0.8
        args:
        - '--watch-dir=/var/grafana-dashboards'
        - '--grafana-url=http://localhost:3000'
        volumeMounts:
        - name: grafana-dashboards
          mountPath: /var/grafana-dashboards
    volumes:
    - name: grafana-dashboards
      configMap:
        name: grafana-dashboards

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboards
data:
  prometheus-datasource.json: |
    {"access":"proxy","basicAuth":true, ... }

  overview-dashboard.json: |
    {"dashboard":{"annotations":{"list":[]}, ... }}

When the dashboard JSON is exported via the Grafana web-ui, it has to be wrapped in {"dashboard": {}}, variables, marked by ${}, have to be replaced and the fields __input and __requires have to be removed, for the dashboard JSON to be parseable by Grafana via the REST API used by the Grafana Watcher.

Alternatively use make generate as described in Developing Alerts and Dashboards to create the ConfigMap.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL