Skip to main content

A wrapper around grafanalib which simplifies generating multiple dashboards.

Project description

Grafana Dashboards Builder

A wrapper around grafanalib which simplifies generating multiple dashboards.

Why?

Grafanalib is a fantastic tool which lets you generate Grafana dashboards from simple Python scripts. Unfortunately, it can only read single files as dashboard sources and doesn't have a concept of multiple output directories. Those limitations make it hard to provision an entire Grafana instance with many folders and multiple dashboard sources.

Grafana Dashboard Builder recursively finds all .dashboard.py files in a directory tree. It generates dashboards and places them in a subdirectories which represent Grafana folders.

It's written with Kubernetes in mind so it can also generate nested output directory structure even when loading sources mounted from a flat ConfigMap (see examples below).

Installation

pip install grafana-dashboards-builder

Usage

grafana-dashboards-builder [OPTIONS] INPUT_DIR [OUTPUT_DIR]

INPUT_DIR is the directory tree with dashboard sources.

OUTPUT_DIR is the directory where generated dashboards are placed (defaults to ./out).

Options:
--from-configmap  generate output directories based on a source files prefix and a '--' separator
--help            Show this message and exit.

Examples

Sources in nested directories

Grafana supports only one level of depth for folders. So even when dashboard sources are nested in multiple subdirectories the output dashboards will have only one parent directory (the most shallow one). Source dashboards that don't have any parent directory will be placed in the default General folder.

For example, given a following input directory tree:

dashboards_in/
    main.dashboard.py
    kubernetes/
        workloads/
            pods.dashboard.py
            jobs.dashboard.py
        nodes/
            nodes.dashboard.py
    nginx/
        nginx_health.dashboard.py

A following output directory will be generated:

dashboards_out/
    General/
        main.json
    Kubernetes/
        pods.json
        jobs.json
        nodes.json
    Nginx/
        nginx_health.json

Sources in a ConfigMap

When running Grafana in Kubernetes cluster it's possible to run Grafana Dashboard Builder as a sidecar which loads dashboard sources from a ConfigMap and generates them into Grafana's /var/lib/grafana/dashboards directory.

ConfigMaps don't support nested directory structures so to enable mapping dashboards to different folders we can prefix the sources filenames with a folder-- prefix. When Grafana Dashboard Builder runs with --from-configmap flag, it parses the filenames and generates output directories based on found prefixes. Filenames without a prefix will be placed in the default General folder.

For example, given a following input directory:

dashboards_in/
    main.dashboard.py
    kubernetes--pods.dashboard.py
    kubernetes--jobs.dashboard.py
    nginx--nginx_health.dashboard.py

A following output directory will be generated:

dashboards_out/
    General/
        main.json
    Kubernetes/
        pods.json
        jobs.json
    Nginx/
        nginx_health.json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grafana-dashboards-builder-0.3.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file grafana-dashboards-builder-0.3.1.tar.gz.

File metadata

  • Download URL: grafana-dashboards-builder-0.3.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.6.10 Linux/4.19.78-coreos

File hashes

Hashes for grafana-dashboards-builder-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2dae7a8c63d6e4c427847a78fcb992d7abeccac5de99777614f1f7f142f8899d
MD5 7cc09c6f2660129f3897bcbfec53e6ce
BLAKE2b-256 3a28a28ad5c9c48914d8ec2ed058be1e03870e5e309aebcf1a203854cf4ac98e

See more details on using hashes here.

File details

Details for the file grafana_dashboards_builder-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for grafana_dashboards_builder-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 919bf9fad83ee9fb5a60d19e1667e57bf8a45342f9b739b48a2563db33bc07ef
MD5 8f9fc0a19b544c687b3c8ce54227e04c
BLAKE2b-256 d004ba64c5c6154785c104da59d799f436912883dcca99b0f274a9497fc8a0fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page