Skip to content

Commit 2936c5b

Browse files
committed
Update documentation
1 parent f5fdfae commit 2936c5b

File tree

2 files changed

+96
-18
lines changed

2 files changed

+96
-18
lines changed

README.md

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ user = grafana.admin.create_user(
4141
user = 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
5050
grafana.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
5959
grafana.organization.create_organization({"name": "new_organization"})
@@ -65,31 +65,49 @@ grafana.organization.create_organization({"name": "new_organization"})
6565
There are two ways to authenticate to the Grafana API. Either use an API token,
6666
or 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
7272
from 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
128181
A 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

docs/backlog.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
# grafana-client backlog
22

3-
- Clarify *"To use admin API you need to use basic auth"*, see README.
3+
## Collected
4+
- [o] Clarify *"To use admin API you need to use basic auth"* in README
5+
- [o] Use appropriate user agent
6+
- [o] Provide example program with grafanalib
7+
- [o] Announcement on https://community.grafana.com/
8+
- [o] Documentation
9+
- [o] Tests
10+
- [o] Real data queries, see https://github.com/panodata/grafana-client/pull/5 ff.
11+
- [o] Provide example program for querying data sources
12+
- [o] Protect against submitting JSON into API methods
13+
- [o] Fix typo: `runnner`
14+
- [o] Make example program `datasource-query.py` fully work
15+
16+
## Community contributions
17+
- [o] Fix "teams" bug
18+
- https://github.com/panodata/grafana-client/issues/12
19+
- https://github.com/changdingfang/grafana_api/commit/e762671
20+
- [o] Alerts API
21+
- https://github.com/stephenlclarke/grafana_api/commit/606b58658e
22+
- [o] Dashboard versions
23+
- https://github.com/DrMxxxxx/grafana_api/commit/fdf47a651be4
24+
- [o] Query range and series
25+
- https://github.com/RalfHerzog/grafana_api/commit/57e1086a7
26+
- https://github.com/RalfHerzog/grafana_api/commit/68d505e

0 commit comments

Comments
 (0)