Skip to content

Commit 79eab1c

Browse files
committed
doc: 📝 First version of the guide on how to use Grafana API
1 parent bf42a5d commit 79eab1c

14 files changed

+723
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Grafana - Tutorial - How to use the Grafana API
3+
slug: grafana/tutorial-using-api
4+
excerpt: "Learn how to use the Grafana API"
5+
section: Grafana - Tutorials
6+
order: 010
7+
updated: 2023-04-06
8+
---
9+
10+
**Last updated 6th April 2023**
11+
12+
## Objective
13+
14+
Using the Grafana is not obvious and already clearly documented.
15+
This tutorial explains how to configure Grafana to use API and how make call to the exposed API.
16+
17+
## Requirements
18+
19+
- A [Public Cloud project](https://www.ovhcloud.com/en-ie/public-cloud/) in your OVHcloud account
20+
- Access to the [OVHcloud Control Panel](https://www.ovh.com/auth/?action=gotomanager&from=https://www.ovh.ie/&ovhSubsidiary=ie)
21+
- A Grafana database running on your OVHcloud Public Cloud project. [This guide](https://docs.ovh.com/ie/en/publiccloud/databases/getting-started/) can help you to create a managed Grafana.
22+
23+
## Instructions
24+
25+
### Create a Grafana service account
26+
27+
In the configuration menu, display the `Service accounts`{.action} tab:
28+
29+
![Grafana service accounts tab](images/service-account-tab.png){.thumbnail}
30+
31+
Create a new service account `sa-editor` with the role `Editor`:
32+
33+
![Grafana service accounts creation](images/service-account-creation.png){.thumbnail}
34+
35+
Click on the `Add service account token`{.action}:
36+
37+
![Grafana service accounts token button](images/add-service-account-token-button.png){.thumbnail}
38+
39+
Enter the name of the desired token, `grafana-sa-token-editor`, and click on the `Generate token`{.action}:
40+
41+
![Grafana service accounts token generation](images/generate-sa-token.png){.thumbnail}
42+
43+
Copy the generated token:
44+
45+
![Grafana service accounts token generated](images/sa-account-generated-token.png){.thumbnail}
46+
47+
> [!warning]
48+
>
49+
> After closing the pop-up, you will no longer be able to display the token!
50+
51+
The created token appears in the tokens list:
52+
53+
![Grafana service accounts token list](images/sa-account-created-tokens-list.png){.thumbnail}
54+
55+
You are ready to use this token with the Grafana API.
56+
57+
### Use the Grafana API
58+
59+
> [!primary]
60+
>
61+
> Detailed instructions on how to use the API and the possible actions can be found in the official documentation: https://grafana.com/docs/grafana/latest/developers/http_api/
62+
63+
> [!warning]
64+
>
65+
> Don't forget to set the `Authorised IP addresses` in the Grafana configuration. See [Configure your Grafana instance to accept incoming connections documentation](https://docs.ovh.com/asia/en/publiccloud/databases/grafana/configure-grafana-instance/) guide for more details.
66+
67+
To send a request to the API you must use the previously created token and set it in the request header as a 'Bearer token':
68+
```bash
69+
export GRAFANA_API_TOKEN=042footoken420
70+
71+
curl -H "Authorization: Bearer $GRAFANA_API_TOKEN" https://grafana-xxxxxxxxx-yyyyyyyyy.database.cloud.ovh.net/api/folders
72+
[
73+
{
74+
"id":11,
75+
"uid":"HnDCAp-4k",
76+
"title":"foo 1"
77+
},
78+
{
79+
"id":5,
80+
"uid":"cb_S6Pb4k",
81+
"title":"foo 2"
82+
},
83+
{
84+
"id":9,
85+
"uid":"Xav55taVk",
86+
"title":"foo 3"
87+
},
88+
{
89+
"id":10,
90+
"uid":"AH8sApaVz",
91+
"title":"foo 4"
92+
}
93+
]
94+
95+
```
96+
97+
Here it is, you can now use all the power of the Grafana's APIs.
98+
99+
## We want your feedback!
100+
101+
We would love to help answer questions and appreciate any feedback you may have.
102+
103+
Are you on Discord? Connect to our channel at <https://discord.gg/PwPqWUpN8G> and interact directly with the team that builds our databases service!
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Grafana - Tutorial - How to use the Grafana API
3+
slug: grafana/tutorial-using-api
4+
excerpt: "Learn how to use the Grafana API"
5+
section: Grafana - Tutorials
6+
order: 010
7+
updated: 2023-04-06
8+
---
9+
10+
**Last updated 6th April 2023**
11+
12+
## Objective
13+
14+
Using the Grafana is not obvious and already clearly documented.
15+
This tutorial explains how to configure Grafana to use API and how make call to the exposed API.
16+
17+
## Requirements
18+
19+
- A [Public Cloud project](https://www.ovhcloud.com/en-ie/public-cloud/) in your OVHcloud account
20+
- Access to the [OVHcloud Control Panel](https://www.ovh.com/auth/?action=gotomanager&from=https://www.ovh.ie/&ovhSubsidiary=ie)
21+
- A Grafana database running on your OVHcloud Public Cloud project. [This guide](https://docs.ovh.com/ie/en/publiccloud/databases/getting-started/) can help you to create a managed Grafana.
22+
23+
## Instructions
24+
25+
### Create a Grafana service account
26+
27+
In the configuration menu, display the `Service accounts`{.action} tab:
28+
29+
![Grafana service accounts tab](images/service-account-tab.png){.thumbnail}
30+
31+
Create a new service account `sa-editor` with the role `Editor`:
32+
33+
![Grafana service accounts creation](images/service-account-creation.png){.thumbnail}
34+
35+
Click on the `Add service account token`{.action}:
36+
37+
![Grafana service accounts token button](images/add-service-account-token-button.png){.thumbnail}
38+
39+
Enter the name of the desired token, `grafana-sa-token-editor`, and click on the `Generate token`{.action}:
40+
41+
![Grafana service accounts token generation](images/generate-sa-token.png){.thumbnail}
42+
43+
Copy the generated token:
44+
45+
![Grafana service accounts token generated](images/sa-account-generated-token.png){.thumbnail}
46+
47+
> [!warning]
48+
>
49+
> After closing the pop-up, you will no longer be able to display the token!
50+
51+
The created token appears in the tokens list:
52+
53+
![Grafana service accounts token list](images/sa-account-created-tokens-list.png){.thumbnail}
54+
55+
You are ready to use this token with the Grafana API.
56+
57+
### Use the Grafana API
58+
59+
> [!primary]
60+
>
61+
> Detailed instructions on how to use the API and the possible actions can be found in the official documentation: https://grafana.com/docs/grafana/latest/developers/http_api/
62+
63+
> [!warning]
64+
>
65+
> Don't forget to set the `Authorised IP addresses` in the Grafana configuration. See [Configure your Grafana instance to accept incoming connections documentation](https://docs.ovh.com/au/en/publiccloud/databases/grafana/configure-grafana-instance/) guide for more details.
66+
67+
To send a request to the API you must use the previously created token and set it in the request header as a 'Bearer token':
68+
```bash
69+
export GRAFANA_API_TOKEN=042footoken420
70+
71+
curl -H "Authorization: Bearer $GRAFANA_API_TOKEN" https://grafana-xxxxxxxxx-yyyyyyyyy.database.cloud.ovh.net/api/folders
72+
[
73+
{
74+
"id":11,
75+
"uid":"HnDCAp-4k",
76+
"title":"foo 1"
77+
},
78+
{
79+
"id":5,
80+
"uid":"cb_S6Pb4k",
81+
"title":"foo 2"
82+
},
83+
{
84+
"id":9,
85+
"uid":"Xav55taVk",
86+
"title":"foo 3"
87+
},
88+
{
89+
"id":10,
90+
"uid":"AH8sApaVz",
91+
"title":"foo 4"
92+
}
93+
]
94+
95+
```
96+
97+
Here it is, you can now use all the power of the Grafana's APIs.
98+
99+
## We want your feedback!
100+
101+
We would love to help answer questions and appreciate any feedback you may have.
102+
103+
Are you on Discord? Connect to our channel at <https://discord.gg/PwPqWUpN8G> and interact directly with the team that builds our databases service!
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Grafana - Tutorial - How to use the Grafana API
3+
slug: grafana/tutorial-using-api
4+
excerpt: "Learn how to use the Grafana API"
5+
section: Grafana - Tutorials
6+
order: 010
7+
updated: 2023-04-06
8+
---
9+
10+
**Last updated 6th April 2023**
11+
12+
## Objective
13+
14+
Using the Grafana is not obvious and already clearly documented.
15+
This tutorial explains how to configure Grafana to use API and how make call to the exposed API.
16+
17+
## Requirements
18+
19+
- A [Public Cloud project](https://www.ovhcloud.com/en-ie/public-cloud/) in your OVHcloud account
20+
- Access to the [OVHcloud Control Panel](https://www.ovh.com/auth/?action=gotomanager&from=https://www.ovh.ie/&ovhSubsidiary=ie)
21+
- A Grafana database running on your OVHcloud Public Cloud project. [This guide](https://docs.ovh.com/ie/en/publiccloud/databases/getting-started/) can help you to create a managed Grafana.
22+
23+
## Instructions
24+
25+
### Create a Grafana service account
26+
27+
In the configuration menu, display the `Service accounts`{.action} tab:
28+
29+
![Grafana service accounts tab](images/service-account-tab.png){.thumbnail}
30+
31+
Create a new service account `sa-editor` with the role `Editor`:
32+
33+
![Grafana service accounts creation](images/service-account-creation.png){.thumbnail}
34+
35+
Click on the `Add service account token`{.action}:
36+
37+
![Grafana service accounts token button](images/add-service-account-token-button.png){.thumbnail}
38+
39+
Enter the name of the desired token, `grafana-sa-token-editor`, and click on the `Generate token`{.action}:
40+
41+
![Grafana service accounts token generation](images/generate-sa-token.png){.thumbnail}
42+
43+
Copy the generated token:
44+
45+
![Grafana service accounts token generated](images/sa-account-generated-token.png){.thumbnail}
46+
47+
> [!warning]
48+
>
49+
> After closing the pop-up, you will no longer be able to display the token!
50+
51+
The created token appears in the tokens list:
52+
53+
![Grafana service accounts token list](images/sa-account-created-tokens-list.png){.thumbnail}
54+
55+
You are ready to use this token with the Grafana API.
56+
57+
### Use the Grafana API
58+
59+
> [!primary]
60+
>
61+
> Detailed instructions on how to use the API and the possible actions can be found in the official documentation: https://grafana.com/docs/grafana/latest/developers/http_api/
62+
63+
> [!warning]
64+
>
65+
> Don't forget to set the `Authorised IP addresses` in the Grafana configuration. See [Configure your Grafana instance to accept incoming connections documentation](https://docs.ovh.com/ca/en/publiccloud/databases/grafana/configure-grafana-instance/) guide for more details.
66+
67+
To send a request to the API you must use the previously created token and set it in the request header as a 'Bearer token':
68+
```bash
69+
export GRAFANA_API_TOKEN=042footoken420
70+
71+
curl -H "Authorization: Bearer $GRAFANA_API_TOKEN" https://grafana-xxxxxxxxx-yyyyyyyyy.database.cloud.ovh.net/api/folders
72+
[
73+
{
74+
"id":11,
75+
"uid":"HnDCAp-4k",
76+
"title":"foo 1"
77+
},
78+
{
79+
"id":5,
80+
"uid":"cb_S6Pb4k",
81+
"title":"foo 2"
82+
},
83+
{
84+
"id":9,
85+
"uid":"Xav55taVk",
86+
"title":"foo 3"
87+
},
88+
{
89+
"id":10,
90+
"uid":"AH8sApaVz",
91+
"title":"foo 4"
92+
}
93+
]
94+
95+
```
96+
97+
Here it is, you can now use all the power of the Grafana's APIs.
98+
99+
## We want your feedback!
100+
101+
We would love to help answer questions and appreciate any feedback you may have.
102+
103+
Are you on Discord? Connect to our channel at <https://discord.gg/PwPqWUpN8G> and interact directly with the team that builds our databases service!

0 commit comments

Comments
 (0)