A cli utility that uses Grafana's HTTP API to easily save and restore dashboards.
Project description
grafana-dashboard-manager
Introduction
A simple CLI utility for importing or exporting dashboard JSON definitions 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 IDs - useful for deploying one set of dashboards across multiple Grafana instances, for instance across environments.
Workflow
The intended workflow is:
- Create a dashboard and save it in the desired folder from within the Grafana web GUI
- Use
grafana-dashboard-manager
to extract the new dashboards and save them to a local directory or version control system. - Dashboards can be created or updated from the local store and uploaded back into Grafana.
Installation
Install via pip:
pip install grafana-dashboard-manager
Install from source - requires Poetry on your system:
cd /path/to/grafana-dashboard-manager
poetry install
Usage
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, the API Key must have admin permissions if you are accessing the API using --token
.
For more help, see the full help text with poetry run grafana-dashboard-manager --help
.
Download dashboards from web to solution-data using the Grafana admin user
poetry run grafana-dashboard-manager \
--host https://my.grafana.com \
--username admin_username --password admin_password \
download all \
--destination-dir /path/to/dashboards/
Download dashboards from web to solution-data using a Grafana admin API Key
poetry run grafana-dashboard-manager \
--host https://my.grafana.com \
--token admin_api_key \
download all \
--destination-dir /path/to/dashboards/
Upload dashboards from solution-data to web using the Grafana admin user
poetry run grafana-dashboard-manager \
--host https://my.grafana.com \
--username admin_username --password admin_password \
upload all \
--source-dir /path/to/dashboards/
Upload dashboards from solution-data to web using a Grafana admin API Key
poetry run grafana-dashboard-manager \
--host https://my.grafana.com \
--token admin_api_key \
upload all \
--source-dir /path/to/dashboards/
Please note: if your Grafana is not hosted on port 80/443 as indicated by the protocol prefix, the port needs to be specified as part of the --host
argument. For example, a locally hosted instance on port 3000: --host http://localhost:3000
.
Limitations
- The home dashboard new deployment needs the default home dashboard to be manually set in the web UI, as the API to set the organisation default dashboard seems to be broken, at least on v8.2.3.
- Currently expects a hardcoded
home.json
dashboard to set as the home. - Does not handle upload of dashboards more deeply nested than Grafana supports.
- 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.1.17.33478076231.tar.gz
.
File metadata
- Download URL: grafana_dashboard_manager-0.1.17.33478076231.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42d9d01527f829f82a473f17b8d1c4ec705527d744dfe4adb6e7549a35480d83 |
|
MD5 | 3e4ec705c8a6edf4783c4e507edd79bd |
|
BLAKE2b-256 | 98b57dabf3df588491b9c7a61ff7b645eb7c5edc434fdb67d2b7c230cdc20f81 |
File details
Details for the file grafana_dashboard_manager-0.1.17.33478076231-py3-none-any.whl
.
File metadata
- Download URL: grafana_dashboard_manager-0.1.17.33478076231-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 627288278b7b19fc3e291986bc6ace292b5a17324f0225775f3318da4654f37e |
|
MD5 | e8b5de129ecec73df7c9f48235af62df |
|
BLAKE2b-256 | 6691684157a124e774763bf143db343ef6dfd8c7d6eb84af79d58bedc8328bfd |