A cli utility that uses Grafana's HTTP API to easily save and restore dashboards.
Project description
grafana-dashboard-manager
A simple CLI utility for importing and exporting dashboards as JSON using the Grafana HTTP API.
This can be used for:
- Backing up your dashboards that already exist within your Grafana instance, e.g. if you are migrating from the internal SQLite database to MySQL.
- Updating dashboard files for your Infrastructure-as-Code for use with Grafana dashboard provisioning.
- Making tweaks to dashboard JSON files directly and updating Grafana with one command.
Features
- Mirrors the folder structure between a local set of dashboards and Grafana, creating folders where necessary.
- Ensures links to dashboards folders in a
dashlist
Panel are consistent with the Folder UIDs - useful for deploying one set of dashboards across multiple Grafana instances, for instance across environments.
Usage
For detailed command help, see the full help text with the
--help
option.
Credentials
It is important to note that the admin login username and password are required, and its selected organization must be correct, if you are accessing the API using --username
and --password
. Alternatively, a provided API Key must have admin permissions if you are accessing the API using --token
.
Docker
A Dockerfile is provided. To build and run:
docker build -t grafana-dashboard-manager:latest .
docker run grafana-dashboard-manager --help
From PyPI
Install via pip:
pip install grafana-dashboard-manager
From source
Install dependencies and run with Poetry
cd /path/to/grafana-dashboard-manager
poetry install
poetry run python ./grafana_dashboard_manager --help
Workflow
The intended workflow is:
- Download dashboards and to a local directory or version control system for backup and change control.
- Replicate across multiple Grafana installs or restore a previous install by uploading the saved dashboards.
Usage Examples
These examples use docker run
commands, but the commands are the same regardless of run method.
Download dashboards using the Grafana admin user:
docker run grafana-dashboard-manager \
download \
--scheme https \
--host my.grafana.example.com \
--username $USERNAME --password $PASSWORD \
--destination /path/to/dashboards/
Download dashboards using a Grafana admin API Key:
docker run grafana-dashboard-manager \
download \
--scheme https \
--host my.grafana.example.com \
--token $API_KEY \
--destination /path/to/dashboards/
Upload dashboards using the Grafana admin user, to a local instance for testing
docker run grafana-dashboard-manager \
upload \
--scheme http \
--port 3000 \
--host localhost \
--username $USERNAME --password $PASSWORD \
--source /path/to/dashboards/
Upload dashboards using a Grafana admin key without any user prompts:
docker run grafana-dashboard-manager \
upload \
--scheme http \
--port 3000 \
--host localhost \
--token $API_KEY \
--source /path/to/dashboards/
Notes
- The scheme is
https
and port is 443 by default. If your Grafana is not hosted with https on 443, the scheme and port needs to be specified using the--scheme
and--port
options respectively. - If you use self signed certs on the Grafana server or otherwise don't want to validate an HTTPS connection, use
--skip-verify
although this is not recommended. - The
version
of the dashboard is removed of the json files in order to allow overwriting and creation of dashboards as new. - URL encoding of strings is handled by httpx and so characters such as
/
in folder names is supported. - When uploading, setting the home dashboard from the
home.json
file can be disabled with the option--skip-home
.
Limitations
- Does not support the experimental nested folders in Grafana. Only one level of folders is supported.
- Does not support multi-organization deployments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file grafana_dashboard_manager-0.2.6.73521613271.tar.gz
.
File metadata
- Download URL: grafana_dashboard_manager-0.2.6.73521613271.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5477b021fc893a52dc1a7abca814d2f6ba4cdfb80ddc6eb054b668641585c6cf |
|
MD5 | 58a89e08c6acf3956e5193aeecf6b8e9 |
|
BLAKE2b-256 | e6b16fc316959371cb872c81f70137b355d9fba738158d9c2f2d55764db9e03a |
File details
Details for the file grafana_dashboard_manager-0.2.6.73521613271-py3-none-any.whl
.
File metadata
- Download URL: grafana_dashboard_manager-0.2.6.73521613271-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/6.2.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7b7f0bee410e0f3208157015ffa917e5984eb01c893c5ce7986dd9ef8bf66d7 |
|
MD5 | 0ada3f02af21ae3c6f337ae5be1a239c |
|
BLAKE2b-256 | fbfa87d53e4878e68910009e1ad2f36c3242f227193b85979d64287052df02c4 |