Skip to main content

grafana-client

Tests Test coverage License

PyPI Python versions Status Downloads

About

A client library for the Grafana HTTP API, written in Python.

History

The library was originally conceived by Andrew Prokhorenkov and contributors as grafana_api. Thank you very much for your efforts!

At future maintenance of grafana_api, we discussed the need for a fork because the repository stopped receiving updates since more than a year.

While forking it, we renamed the package to grafana-client and slightly trimmed the module namespace.

Getting started

Install the package from PyPI.

pip install grafana-client --upgrade

Connect to your Grafana API endpoint using the GrafanaApi class.

from grafana_client import GrafanaApi

grafana = GrafanaApi(auth='eyJrIjoiWHg...dGJpZCI6MX0=', host='grafana.example.org')

# Create user
user = grafana.admin.create_user(
    {"name": "User", "email": "user@example.org", "login": "user", "password": "userpassword", "OrgId": 1})

# Change user password
user = grafana.admin.change_user_password(2, "newpassword")

# Search dashboards based on tag
grafana.search.search_dashboards(tag='applications')

# Find a user by email
user = grafana.users.find_user('test@example.org')

# Add user to team 2
grafana.teams.add_team_member(2, user["id"])

# Create or update a dashboard
grafana.dashboard.update_dashboard(dashboard={'dashboard': {...}, 'folderId': 0, 'overwrite': True})

# Delete a dashboard by UID
grafana.dashboard.delete_dashboard(dashboard_uid='abcdefgh')

# Create organization
grafana.organization.create_organization({"name": "new_organization"})

Authentication

There are two ways to authenticate to the Grafana API. Either use an API token, or HTTP basic auth.

To use the admin API, you need to use HTTP basic auth, as stated at the Grafana Admin API documentation.

from grafana_client import GrafanaApi

# Use HTTP basic authentication
grafana = GrafanaApi(
    auth=("username", "password"),
    host='grafana.example.org'
)

# Use Grafana API token
grafana = GrafanaApi(
    auth='eyJrIjoiWHg...dGJpZCI6MX0=',
    host='grafana.example.org'
)

Status

This table outlines which parts of Grafana's HTTP API are covered by grafana-client, see also Grafana HTTP API reference.

API Status
Admin +
Alerting -
Alerting Notification Channels +
Annotations +
Authentication +-
Dashboard +
Dashboard Versions -
Dashboard Permissions +
Data Source +
Folder +
Folder Permissions +
Folder/Dashboard Search +-
Health +
Organisation +
Other +
Preferences +
Snapshot +
Teams +
User +

Software tests

python3 -m venv .venv
source .venv/bin/activate
pip install --editable=.[test]
python -m unittest -vvv

Acknowledgements

Thanks to all the contributors who helped to co-create and conceive this software in one way or another. You know who you are.

Contributing

Any kind of contribution and feedback are very much welcome! Just create an issue or submit a patch if you think we should include a new feature, or to report or fix a bug.

The issue tracker URL is: https://github.com/panodata/grafana-client/issues

License

grafana-client is licensed under the terms of the MIT License, see LICENSE file.

Release files for grafana-client 2.2.1

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-client 2.2.1
File Size Uploaded
grafana-client-2.2.1.tar.gz 28.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grafana-client 2.2.1
File Interpreter ABI Platform
grafana_client-2.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 59.4 kB

Release files / grafana-client-2.2.1.tar.gz

Download URL grafana-client-2.2.1.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
683573ba11699e9df63c755a2fd140cbca1d31ed3aedc98366fcde8e6e4014d4
BLAKE2b-256 checksum
How to use checksums
0b6403f769ee69a36a8817b313e983e95343dd1a3a3e1306061347903ed06054
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release files / grafana_client-2.2.1-py2.py3-none-any.whl

Download URL grafana_client-2.2.1-py2.py3-none-any.whl
Size 30.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bce1d2621acacf5153b9fa370e57b652fa1a56c2fcb73d26534dbb5fa41df4dd
BLAKE2b-256 checksum
How to use checksums
da384915e5a723e68f5334fc8b22ec2bd6bdb57c894055b1908c549bb6184a8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release history Release notifications | RSS feed

5.1.2

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.3.0

2 release files

4.2.4

2 release files

4.2.3

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.10.0

2 release files

3.9.2

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.3.0

2 release files

This release

2.2.1 This release

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

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