Skip to main content

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

Metadata

Release files for grafana-dashboards-builder 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grafana-dashboards-builder 0.3.1
File Size Uploaded Provenance Actions
grafana-dashboards-builder-0.3.1.tar.gz 5.2 kB Without provenance Details for grafana-dashboards-builder-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grafana-dashboards-builder 0.3.1
File Interpreter ABI Platform Actions
grafana_dashboards_builder-0.3.1-py3-none-any.whl Python 3 none any Details for grafana_dashboards_builder-0.3.1-py3-none-any.whl

Total release size: 10.8 kB

Release files / grafana-dashboards-builder-0.3.1.tar.gz

Download URL grafana-dashboards-builder-0.3.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2dae7a8c63d6e4c427847a78fcb992d7abeccac5de99777614f1f7f142f8899d
BLAKE2b-256 checksum
How to use checksums
3a28a28ad5c9c48914d8ec2ed058be1e03870e5e309aebcf1a203854cf4ac98e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.6.10 Linux/4.19.78-coreos

Release files / grafana_dashboards_builder-0.3.1-py3-none-any.whl

Download URL grafana_dashboards_builder-0.3.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
919bf9fad83ee9fb5a60d19e1667e57bf8a45342f9b739b48a2563db33bc07ef
BLAKE2b-256 checksum
How to use checksums
d004ba64c5c6154785c104da59d799f436912883dcca99b0f274a9497fc8a0fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.6.10 Linux/4.19.78-coreos

Security for grafana-dashboards-builder 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page