Skip to main content

A Grafana API SDK

Project description

Grafana API SDK

The repository includes an SDK for the Grafana API. It's possible to communicate with the Grafana API endpoints. Another feature of the SDK is the possibility to specify the used folder for the dashboard.

Currently, supported features

Dashboard

  • Create/ Update a dashboard
  • Delete a dashboard
  • Get permissions of a dashboard
  • Update the permissions of a dashboard
  • Get all dashboard versions
  • Get dashboard version of a specific dashboard
  • Restore a dashboard version of a specific dashboard
  • Compare two dashboard versions and extract the diff between booth dashboards

Folder

  • Get folder id by dashboard path
  • Get all folder ids and folder names
  • Get all folders
  • Get folder by uid
  • Get folder by id
  • Create a folder
  • Update a folder
  • Delete a folder
  • Get permissions for a folder
  • Update permissions for a folder

Search

  • Execute a custom query against the Grafana search endpoint

Datasource

  • Get all datasources
  • Get the datasource by id
  • Get the datasource by uid
  • Get the datasource by name
  • Get the datasource id by name
  • Create a new datasource
  • Update a datasource
  • Delete a datasource by id
  • Delete a datasource by uid
  • Delete a datasource by name
  • Query a datasource by id
  • Enabled datasource permissions
  • Disable datasource permissions
  • Get datasource permissions
  • Add datasource permissions
  • Delete datasource permissions

Legacy Alerting

  • Get alerts
  • Get alerts by dashboard ids
  • Get alert by id
  • Pause alert by id
  • Unpause alert by id

Alerting

  • Get all Alertmanager alerts

  • Create or update Alertmanager alerts

  • Get Alertmanager group alerts

  • Get all Alertmanager silences

  • Get Alertmanager silence by id

  • Create or update Alertmanager silence

  • Delete Alertmanager silence by id

  • Get Alertmanager status

  • Get the Alertmanager config

  • Create or update the Alertmanager config

  • Delete the Alertmanager config

  • Test the Alertmanager receivers

  • Get Prometheus alerts

  • Get Prometheus rules

  • Get Ruler rules

  • Get a Ruler group

  • Get Ruler groups by the namespace

  • Create or update the Ruler group by the namespace

  • Delete a Ruler group

  • Delete a Ruler namespace

  • Test a datasource rule

  • Test a recipient rule

  • Get the NGAlert organization configuration

  • Get the NGAlert Alertmanager configuration by the organization

  • Create or update the NGAlert organization configuration

  • Delete the NGAlert organization configuration

Alerting Channels

  • Get all notification channels
  • Get all notification channels (lookup)
  • Get a notification channel by id
  • Get a notification channel by uid
  • Create an notification channel
  • Update a notification channel by id
  • Update a notification channel by uid
  • Delete a notification channel by id
  • Delete a notification channel by uid
  • Test a notification channel

Feature timeline

The following table describes the plan to implement the rest of the Grafana API functionality. Please, open an issue and vote them up, if you prefer a faster implementation of an API functionality.

API endpoint group Implementation week Maintainer PR State
Admin HTTP API
Annotations HTTP API
Authentication HTTP API
External Group Sync HTTP API
Fine-grained access control HTTP API
HTTP Preferences API
HTTP Snapshot API
Library Element HTTP API
Licensing HTTP API
Organization HTTP API 13 In process
Other HTTP API
Playlist HTTP API
Reporting API
Short URL HTTP API 13 In process
Team HTTP API
User HTTP API

Installation

pip install grafana-api-sdk

Example

import json

from grafana_api.model import APIModel
from grafana_api.dashboard import Dashboard

model: APIModel = APIModel(host="test", token="test")

dashboard: Dashboard = Dashboard(model)

with open("/tmp/test/test.json") as file:
    json_dashboard = json.load(file)

dashboard.create_or_update_dashboard(message="Create a new test dashboard", dashboard_json=json_dashboard, dashboard_path="test")

Templating

If you want to template your JSON document based on a predefined folder structure you can check out one of my other project and integrate the functionality inside your code.

Contribution

If you would like to contribute something, have an improvement request, or want to make a change inside the code, please open a pull request.

Support

If you need support, or you encounter a bug, please don't hesitate to open an issue.

Donations

If you would like to support my work, I ask you to take an unusual action inside the open source community. Donate the money to a non-profit organization like Doctors Without Borders or the Children's Cancer Aid. I will continue to build tools because I like it and it is my passion to develop and share applications.

License

This product is available under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grafana-api-sdk-0.0.3.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

grafana_api_sdk-0.0.3-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file grafana-api-sdk-0.0.3.tar.gz.

File metadata

  • Download URL: grafana-api-sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for grafana-api-sdk-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f8585c697f5ef18d1341dbf3aa234f3ccd49ce5f0197f2131a1a379a5c728ba8
MD5 fcd5007c97882bf20f303ce8a4ee2f9a
BLAKE2b-256 482ef7b9c0f9d721a1de7105dfb7e889c1aed22224b8cb3d1b79536c1b373ec3

See more details on using hashes here.

File details

Details for the file grafana_api_sdk-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: grafana_api_sdk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for grafana_api_sdk-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fff86a8db033c077350fa68833752b25b4c38be0ba164d2479bd1d87885d06a1
MD5 dd9bc789682105b3e11f6fdbe8c63401
BLAKE2b-256 4199992915dbee5e574fcf5d2c45b50b97e7cd80f47a8e7b85a49dc0fb1727ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page