Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

grafana-dashboard-builder

PyPI version Build Status Coverage Status

Introduction

grafana-dashboard-builder is an open-source tool for easier creation of Grafana dashboards. It is written in Python and uses YAML descriptors for dashboard templates.

This project has been inspired by Jenkins Job Builder that allows users to describe Jenkins jobs with human-readable format. grafana-dashboard-builder aims to provide similar simplicity to Grafana dashboard creation and to give users easy way how they can create dashboard templates filled with different configuration.

Installation

To install:

pip install grafana-dashboard-builder

or

uv run pip install -e .

An alternative to installing it into the global site-packages is to add it to your user local directory (usually ~/.local).

pip install --user grafana-dashboard-builder

Usage

After installation you'll find grafana-dashboard-builder on your path. Help can be printed by --help command-line option.

usage: grafana-dashboard-builder [-h] -p PATH [PATH ...] [--project PROJECT] [-o OUT] [-c CONFIG]
                                 [--context CONTEXT] [--plugins PLUGINS [PLUGINS ...]]
                                 [--exporter EXPORTERS [EXPORTERS ...]]

optional arguments:
  -h, --help            show this help message and exit
  -p PATH [PATH ...], --path PATH [PATH ...]
                        List of path to YAML definition files
  --project PROJECT     (deprecated, use path) Location of the file containing
                        project definition.
  -o OUT, --out OUT     (deprecated, use config file and file exporter) Path
                        to output folder
  -c CONFIG, --config CONFIG
                        Configuration file containing fine-tuned setup of
                        builder's components.
  --context CONTEXT     YAML structure defining parameters for dashboard
                        definition. Effectively overrides any parameter
                        defined on project level.
  --plugins PLUGINS [PLUGINS ...]
                        List of external component plugins to load
  --exporter EXPORTERS [EXPORTERS ...]
                        List of dashboard exporters

To start you need to create project configuration that needs to be in one YAML document. And some examples with current can be found in sample project:

grafana-dashboard-builder -p ./samples/project.yaml --exporter file --config ./samples/config.yaml

Exporters

grafana-dashboard-builder provides several builtin exporters that can be enabled through --exporter option. Configuration for all of them is to be provided in configuration file given in --config option. Look at sample config.

File exporter

File exporter is used when you want to store dashboards as JSON files on your local disk.

file:
  output_folder: /some/directory/on/my/disk

To use file exporter run grafana-dashboard-builder with --exporter file option.

grafana-dashboard-builder currently supports persisting dashboards to Elastic Search used by Grafana prior to version 2.0

To configure Elastic Search endpoint put following structure to your configuration file:

elastic-search:
  host: https://this-is-my-domain.com
  password: my_password
  username: my_username

With this configuration your dashboard will be uploaded to https://this-is-my-domain.com/es/grafana-dash/dashboard/dashboard_name

If you do not want to store your credentials in the configuration file you can use environment variables ES_PASSWORD and ES_USERNAME.

To use elastic search exporter run grafana-dashboard-builder with --exporter elastic-search option.

Grafana API

grafana-dashboard-builder currently supports Grafana version 2.0 API.

To configure Grafana endpoint put following structure to your configuration file:

grafana:
  host: https://this-is-my-domain.com
  password: my_password
  username: my_username

With this configuration your dashboard will be POSTed to https://this-is-my-domain.com/api/dashboards/db

If you do not want to store your credentials in the configuration file you can use environment variables GRAFANA_PASSWORD and GRAFANA_USERNAME.

You can use Organization API Key to access Grafana API:

Set token in your configuration file:

grafana:
  host: https://this-is-my-domain.com
  token: eyJrIjoiOGNTW...o2b2123kO==

Or in GRAFANA_TOKEN environment variable.

Read more about authentication in Grafana docs.

To use Grafana exporter run grafana-dashboard-builder with --exporter grafana option.

Supported data stores

At this moment grafana-dashboard-builder supports following data stores:

YAML definition format

Each component follows the same configuration format. Top level must contain 2 fields - name and component type. Under component type is wrapped definition of the component.

- name: some-name
  component-type:
    component-param1: param-value
    component-param2: other-value

Components can be defined in multiple source files that are passed through --path option. If a path is directory it is recursively walked and all files are processed.

Components

Components define basic building blocks such as rows, graphs and template queries. They can be defined in-place or be named and reused within other components and dashboards.

Components can define parameters that can be passed from parent component to its children.

- name: graph-name
  panels:
    - graph:
        target: target
        y_formats: [bytes, short]
        span: 4
- name: row-name
  rows:
    - row:
        title: Placeholder row
        panels:
            - graph-name
            - graph:
                target: target
                y_formats: [bytes, short]
                span: 4

Another component is template queries that allow you to define just one query string for hierarchical variables. Each query part that starts with $ sign will appear as one variable.

- name: template-name
  templates:
    - query:
        query: '{metric-prefix}.$component.$application'

Dashboard

Dashboard is top-level object composed of several components.

- name: overview
  dashboard:
    title: overview dashboard
    time_options: [1h]
    refresh_intervals: [5m]
    templates:
      - template-name:
            metric-prefix: '{metric-prefix}'
    time:
      from: now-12h
      to: now
    rows:
      - row-name

Project

Project is an entry point for builder and defines which dashboards will be generated and provides parameters to them.

- name: Example project
  project:
    dashboard-prefix: MyApp
    metric-prefix: metric.prefix
    dashboards:
        - overview

The biggest benefit of grafana-dashboard-builder is that you can generate several dashboards from one dashboard template just by defining multiple values for a parameter that is contained in dashboard name. Following project will generate 2 dashboards named prefix1-dashboard and prefix2-dashboard.

- name: Example project
  project:
    dashboard-prefix:
      - prefix1
      - prefix2
    dashboards:
      - '{dashboard-prefix}-dashboard'

External context definition

Thanks to project component you can use one dashboard template and configure it with different parameters. But what if you need to use different params based on the Grafana you are uploading dashboards to. That's why you can define configuration externally to your projects and dashboard templates.

You can reference configuration stored in YAML with -config option or even inline it to --context option. External configuration file can look like:

context:
  region: eu
  default-datacenter: cze

Run tox test suite

tox .

Release files for grafana-dashboard-builder 0.10.0a3

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-dashboard-builder 0.10.0a3
File Size Uploaded
grafana_dashboard_builder-0.10.0a3.tar.gz 22.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grafana-dashboard-builder 0.10.0a3
File Interpreter ABI Platform
grafana_dashboard_builder-0.10.0a3-py3-none-any.whl Python 3 none any Details

Total release size: 63.2 kB

Release files / grafana_dashboard_builder-0.10.0a3.tar.gz

Download URL grafana_dashboard_builder-0.10.0a3.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9b52b26041d1897b3c2270e4678259e6bc84687aff22495510765dc84b1e9d55
BLAKE2b-256 checksum
How to use checksums
c916571e74b0f6f6ee6d4c6089af1ea54ed04ff2d06ac792b919bb272b9a4332
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2025.

Transparency log

Release files / grafana_dashboard_builder-0.10.0a3-py3-none-any.whl

Download URL grafana_dashboard_builder-0.10.0a3-py3-none-any.whl
Size 40.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03a64bc969f803a332dfb156ec8c29b462944fddf77017929e81def1f43431d8
BLAKE2b-256 checksum
How to use checksums
d8eb01501be21190edc718b3b55d3080d72bcd82aed703356211e225a5140388
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.10.0a3 This release

2 release files

0.1.0a10

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