# grafana-dashboard-manager
![CodeQL](https://github.com/Beam-Connectivity/grafana-dashboard-manager/actions/workflows/codeql-analysis.yml/badge.svg)
[![PyPI version](https://badge.fury.io/py/grafana_dashboard_manager.svg)](https://badge.fury.io/py/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](https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards).
- 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:
```sh
docker build -t grafana-dashboard-manager:latest .
docker run grafana-dashboard-manager --help
```
### From PyPI
Install via _[pip](https://pypi.org/project/pip/)_:
```sh
pip install grafana-dashboard-manager
```
### From source
Install dependencies and run with _[Poetry](https://python-poetry.org/)_
```sh
cd /path/to/grafana-dashboard-manager
poetry install
poetry run python ./grafana_dashboard_manager --help
```
## Workflow
The intended workflow is:
1. Download dashboards and to a local directory or version control system for backup and change control.
1. 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:
```sh
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:
```sh
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
```sh
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:
```sh
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.
Raw data
{
"_id": null,
"home_page": "https://www.beamconnectivity.com",
"name": "grafana_dashboard_manager",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "grafana, dashboard, json",
"author": "Vince Chan",
"author_email": "vince@beamconnectivity.com",
"download_url": "https://files.pythonhosted.org/packages/f1/d2/6e276e6fbed848f9ddd6e8ccd51b0c2aa71e307ae69dfa7302275af20b71/grafana_dashboard_manager-0.2.10.92469056881.tar.gz",
"platform": null,
"description": "# grafana-dashboard-manager\n\n![CodeQL](https://github.com/Beam-Connectivity/grafana-dashboard-manager/actions/workflows/codeql-analysis.yml/badge.svg)\n[![PyPI version](https://badge.fury.io/py/grafana_dashboard_manager.svg)](https://badge.fury.io/py/grafana_dashboard_manager)\n\nA simple CLI utility for importing and exporting dashboards as JSON using the Grafana HTTP API.\n\nThis can be used for:\n\n- Backing up your dashboards that already exist within your Grafana instance, e.g. if you are migrating from the internal SQLite database to MySQL.\n- Updating dashboard files for your Infrastructure-as-Code for use with [Grafana dashboard provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards).\n- Making tweaks to dashboard JSON files directly and updating Grafana with one command.\n\n## Features\n\n- Mirrors the folder structure between a local set of dashboards and Grafana, creating folders where necessary.\n- 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.\n\n## Usage\n\n> For detailed command help, see the full help text with the `--help` option.\n\n### Credentials\n\nIt 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`.\n\n### Docker\n\nA Dockerfile is provided. To build and run:\n\n```sh\ndocker build -t grafana-dashboard-manager:latest .\ndocker run grafana-dashboard-manager --help\n```\n\n### From PyPI\n\nInstall via _[pip](https://pypi.org/project/pip/)_:\n\n```sh\npip install grafana-dashboard-manager\n```\n\n### From source\n\nInstall dependencies and run with _[Poetry](https://python-poetry.org/)_\n\n```sh\ncd /path/to/grafana-dashboard-manager\npoetry install\npoetry run python ./grafana_dashboard_manager --help\n```\n\n## Workflow\n\nThe intended workflow is:\n\n1. Download dashboards and to a local directory or version control system for backup and change control.\n1. Replicate across multiple Grafana installs or restore a previous install by uploading the saved dashboards.\n\n## Usage Examples\n\nThese examples use `docker run` commands, but the commands are the same regardless of run method.\n\nDownload dashboards using the Grafana admin user:\n\n```sh\ndocker run grafana-dashboard-manager \\\n download \\\n --scheme https \\\n --host my.grafana.example.com \\\n --username $USERNAME --password $PASSWORD \\\n --destination /path/to/dashboards/\n```\n\nDownload dashboards using a Grafana admin API Key:\n\n```sh\ndocker run grafana-dashboard-manager \\\n download \\\n --scheme https \\\n --host my.grafana.example.com \\\n --token $API_KEY \\\n --destination /path/to/dashboards/\n```\n\nUpload dashboards using the Grafana admin user, to a local instance for testing\n\n```sh\ndocker run grafana-dashboard-manager \\\n upload \\\n --scheme http \\\n --port 3000 \\\n --host localhost \\\n --username $USERNAME --password $PASSWORD \\\n --source /path/to/dashboards/\n```\n\nUpload dashboards using a Grafana admin key without any user prompts:\n\n```sh\ndocker run grafana-dashboard-manager \\\n upload \\\n --scheme http \\\n --port 3000 \\\n --host localhost \\\n --token $API_KEY \\\n --source /path/to/dashboards/\n```\n\n## \u00a0Notes\n\n- 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.\n- 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.\n- The `version` of the dashboard is removed of the json files in order to allow overwriting and creation of dashboards as new.\n- URL encoding of strings is handled by httpx and so characters such as `/` in folder names is supported.\n- When uploading, setting the home dashboard from the `home.json` file can be disabled with the option `--skip-home`.\n\n## Limitations\n\n- Does not support the experimental nested folders in Grafana. Only one level of folders is supported.\n- Does not support multi-organization deployments.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A cli utility that uses Grafana's HTTP API to easily save and restore dashboards.",
"version": "0.2.10.92469056881",
"project_urls": {
"Homepage": "https://www.beamconnectivity.com",
"Repository": "https://github.com/Beam-Connectivity/grafana-dashboard-manager"
},
"split_keywords": [
"grafana",
" dashboard",
" json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "27a8ea2fe8bf32b1dcc75c0de12eb34d35e4baa690cf2a99be9888170b261600",
"md5": "0b5de420f803143ddf415107dc1625aa",
"sha256": "06b8b3f8579f9d956940c36afa0789633cd71aa4b585b8361fab8438aca95d18"
},
"downloads": -1,
"filename": "grafana_dashboard_manager-0.2.10.92469056881-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0b5de420f803143ddf415107dc1625aa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 22494,
"upload_time": "2024-05-26T23:20:58",
"upload_time_iso_8601": "2024-05-26T23:20:58.705601Z",
"url": "https://files.pythonhosted.org/packages/27/a8/ea2fe8bf32b1dcc75c0de12eb34d35e4baa690cf2a99be9888170b261600/grafana_dashboard_manager-0.2.10.92469056881-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f1d26e276e6fbed848f9ddd6e8ccd51b0c2aa71e307ae69dfa7302275af20b71",
"md5": "a76391a3a6e207c1a978e2b837851f49",
"sha256": "8273393a13a43bbcdee3f7a7d17e95e12637498b3ac6bff8ada7006eef81cd8d"
},
"downloads": -1,
"filename": "grafana_dashboard_manager-0.2.10.92469056881.tar.gz",
"has_sig": false,
"md5_digest": "a76391a3a6e207c1a978e2b837851f49",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 15200,
"upload_time": "2024-05-26T23:21:00",
"upload_time_iso_8601": "2024-05-26T23:21:00.824708Z",
"url": "https://files.pythonhosted.org/packages/f1/d2/6e276e6fbed848f9ddd6e8ccd51b0c2aa71e307ae69dfa7302275af20b71/grafana_dashboard_manager-0.2.10.92469056881.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-26 23:21:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Beam-Connectivity",
"github_project": "grafana-dashboard-manager",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "grafana_dashboard_manager"
}