@@ -41,19 +41,19 @@ user = grafana.admin.create_user(
4141user = grafana.admin.change_user_password(2 , " newpassword" )
4242
4343# Search dashboards based on tag
44- grafana.search.search_dashboards(tag = ' applications' )
44+ grafana.search.search_dashboards(tag = " applications" )
4545
4646# Find a user by email
47- user
= grafana.users.find_user(
' [email protected] ' )
47+ user
= grafana.users.find_user(
" [email protected] " )
4848
4949# Add user to team 2
5050grafana.teams.add_team_member(2 , user[" id" ])
5151
5252# Create or update a dashboard
53- grafana.dashboard.update_dashboard(dashboard = {' dashboard' : {... }, ' folderId' : 0 , ' overwrite' : True })
53+ grafana.dashboard.update_dashboard(dashboard = {" dashboard" : {... }, " folderId" : 0 , " overwrite" : True })
5454
5555# Delete a dashboard by UID
56- grafana.dashboard.delete_dashboard(dashboard_uid = ' abcdefgh ' )
56+ grafana.dashboard.delete_dashboard(dashboard_uid = " foobar " )
5757
5858# Create organization
5959grafana.organization.create_organization({" name" : " new_organization" })
@@ -65,31 +65,49 @@ grafana.organization.create_organization({"name": "new_organization"})
6565There are two ways to authenticate to the Grafana API. Either use an API token,
6666or HTTP basic auth.
6767
68- To use the admin API, you need to use HTTP basic auth , as stated at the
69- [ Grafana Admin API documentation] .
68+ To use the admin API, you need to use HTTP basic authentication , as stated at
69+ the [ Grafana Admin API documentation] .
7070
7171``` python
7272from grafana_client import GrafanaApi
7373
74- # Use HTTP basic authentication
75- grafana = GrafanaApi(
76- auth = ( " username " , " password " ) ,
77- host = ' grafana.example.org '
74+ # Use Grafana API token.
75+ grafana = GrafanaApi.from_url (
76+ url = " https://grafana.example.org/grafana " ,
77+ auth = " eyJrIjoiWHg...dGJpZCI6MX0= " ,
7878)
7979
80- # Use Grafana API token
81- grafana = GrafanaApi(
82- auth = ' eyJrIjoiWHg...dGJpZCI6MX0=' ,
83- host = ' grafana.example.org'
80+ # Use HTTP basic authentication.
81+ grafana = GrafanaApi.from_url(
82+ url = " https://username:[email protected] /grafana" ,
8483)
84+
85+ # Optionally turn off TLS certificate verification.
86+ grafana = GrafanaApi.from_url(
87+ url = " https://username:[email protected] /grafana?verify=false" ,
88+ )
89+
90+ # Use `GRAFANA_URL` and `GRAFANA_TOKEN` environment variables.
91+ grafana = GrafanaApi.from_env()
92+ ```
93+
94+ ## Proxy
95+
96+ The underlying ` requests ` library honors the ` HTTP_PROXY ` and ` HTTPS_PROXY `
97+ environment variables. Setting them before invoking an application using
98+ ` grafana-client ` has been confirmed to work. For example:
99+ ```
100+ export HTTP_PROXY=10.10.1.10:3128
101+ export HTTPS_PROXY=10.10.1.11:1080
85102```
86103
87104
88- ## Status
105+ ## Details
89106
90- This table outlines which parts of Grafana's HTTP API are covered by
91- ` grafana-client ` , see also [ Grafana HTTP API reference] .
107+ This section of the documentation outlines which parts of the Grafana HTTP API
108+ are supported, and to which degree. See also [ Grafana HTTP API reference] .
92109
110+ ### Overview
93111
94112| API | Status |
95113| ---| ---|
@@ -114,6 +132,41 @@ This table outlines which parts of Grafana's HTTP API are covered by
114132| User | + |
115133
116134
135+ ### Data source health check
136+
137+ #### Introduction
138+
139+ For checking whether a Grafana data source is healthy, Grafana 9 has a
140+ server-side data source health check API. For earlier versions, a client-side
141+ implementation is provided.
142+
143+ This implementation works in the same manner as the "Save & test" button works,
144+ when creating a data source in the user interface.
145+
146+ The feature can be explored through corresponding client programs in the
147+ ` examples/ ` folder of this repository.
148+
149+ #### Compatibility
150+
151+ The minimum supported version is Grafana 7.x, it does not work on older
152+ versions of Grafana. Prometheus only works on Grafana 8.x and newer.
153+
154+ #### Data source coverage
155+
156+ Support for data source health checks on those Grafana data sources is
157+ implemented as of June 2022.
158+
159+ - CrateDB
160+ - Elasticsearch
161+ - InfluxDB
162+ - PostgreSQL
163+ - Prometheus
164+ - Testdata
165+
166+ We are humbly asking the community to contribute adapters for other data
167+ sources.
168+
169+
117170## Software tests
118171
119172``` shell
@@ -128,8 +181,10 @@ python -m unittest -vvv
128181A list of applications based on ` grafana-client ` .
129182
130183- [ grafana-import-tool] ( https://github.com/peekjef72/grafana-import-tool )
184+ - [ grafana-ldap-sync-script] ( https://github.com/NovatecConsulting/grafana-ldap-sync-script )
131185- [ grafana-snapshots-tool] ( https://github.com/peekjef72/grafana-snapshots-tool )
132186- [ grafana-wtf] ( https://github.com/panodata/grafana-wtf )
187+ - [ nixops-grafana] ( https://github.com/tewfik-ghariani/nixops-grafana )
133188
134189
135190## History
0 commit comments