mirror of https://github.com/grafana/grafana
prometheushacktoberfestmetricsmonitoringalertinggrafanagoinfluxdbmysqlpostgresanalyticsdata-visualizationdashboardbusiness-intelligenceelasticsearch
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
9.2 KiB
354 lines
9.2 KiB
|
8 years ago
|
+++
|
||
|
4 years ago
|
aliases = ["/docs/grafana/latest/http_api/annotations/"]
|
||
|
8 years ago
|
description = "Grafana Annotations HTTP API"
|
||
|
|
keywords = ["grafana", "http", "documentation", "api", "annotation", "annotations", "comment"]
|
||
|
4 years ago
|
title = "Annotations HTTP API "
|
||
|
8 years ago
|
+++
|
||
|
|
|
||
|
4 years ago
|
# Annotations API
|
||
|
8 years ago
|
|
||
|
4 years ago
|
This is the API documentation for the new Grafana Annotations feature released in Grafana 4.6. Annotations are saved in the Grafana database (sqlite, mysql or postgres). Annotations can be organization annotations that can be shown on any dashboard by configuring an annotation data source - they are filtered by tags. Or they can be tied to a panel on a dashboard and are then only shown on that panel.
|
||
|
|
|
||
|
4 years ago
|
> If you are running Grafana Enterprise and have [Role-based access control]({{< relref "../../enterprise/access-control/_index.md" >}}) enabled, access to endpoints will be controlled by role-based access control permissions.
|
||
|
4 years ago
|
> Refer to specific endpoints to understand what permissions are required.
|
||
|
8 years ago
|
|
||
|
|
## Find Annotations
|
||
|
|
|
||
|
|
`GET /api/annotations?from=1506676478816&to=1507281278816&tags=tag1&tags=tag2&limit=100`
|
||
|
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
4 years ago
|
| Action | Scope |
|
||
|
|
| ---------------- | ----------------------- |
|
||
|
|
| annotations:read | annotations:type:<type> |
|
||
|
4 years ago
|
|
||
|
8 years ago
|
**Example Request**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
GET /api/annotations?from=1506676478816&to=1507281278816&tags=tag1&tags=tag2&limit=100 HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
|
Content-Type: application/json
|
||
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
||
|
|
```
|
||
|
|
|
||
|
|
Query Parameters:
|
||
|
|
|
||
|
|
- `from`: epoch datetime in milliseconds. Optional.
|
||
|
|
- `to`: epoch datetime in milliseconds. Optional.
|
||
|
8 years ago
|
- `limit`: number. Optional - default is 100. Max limit for results returned.
|
||
|
8 years ago
|
- `alertId`: number. Optional. Find annotations for a specified alert.
|
||
|
|
- `dashboardId`: number. Optional. Find annotations that are scoped to a specific dashboard
|
||
|
|
- `panelId`: number. Optional. Find annotations that are scoped to a specific panel
|
||
|
8 years ago
|
- `userId`: number. Optional. Find annotations created by a specific user
|
||
|
|
- `type`: string. Optional. `alert`|`annotation` Return alerts or user created annotations
|
||
|
4 years ago
|
- `tags`: string. Optional. Use this to filter organization annotations. Organization annotations are annotations from an annotation data source that are not connected specifically to a dashboard or panel. To do an "AND" filtering with multiple tags, specify the tags parameter multiple times e.g. `tags=tag1&tags=tag2`.
|
||
|
8 years ago
|
|
||
|
|
**Example Response**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"id": 1124,
|
||
|
|
"alertId": 0,
|
||
|
|
"dashboardId": 468,
|
||
|
4 years ago
|
"dashboardUID": "uGlb_lG7z",
|
||
|
8 years ago
|
"panelId": 2,
|
||
|
|
"userId": 1,
|
||
|
|
"userName": "",
|
||
|
|
"newState": "",
|
||
|
|
"prevState": "",
|
||
|
|
"time": 1507266395000,
|
||
|
6 years ago
|
"timeEnd": 1507266395000,
|
||
|
8 years ago
|
"text": "test",
|
||
|
|
"metric": "",
|
||
|
|
"tags": [
|
||
|
|
"tag1",
|
||
|
|
"tag2"
|
||
|
|
],
|
||
|
|
"data": {}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"id": 1123,
|
||
|
|
"alertId": 0,
|
||
|
|
"dashboardId": 468,
|
||
|
4 years ago
|
"dashboardUID": "jcIIG-07z",
|
||
|
8 years ago
|
"panelId": 2,
|
||
|
|
"userId": 1,
|
||
|
|
"userName": "",
|
||
|
|
"newState": "",
|
||
|
|
"prevState": "",
|
||
|
|
"time": 1507265111000,
|
||
|
|
"text": "test",
|
||
|
|
"metric": "",
|
||
|
|
"tags": [
|
||
|
|
"tag1",
|
||
|
|
"tag2"
|
||
|
|
],
|
||
|
|
"data": {}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
```
|
||
|
|
|
||
|
6 years ago
|
> Starting in Grafana v6.4 regions annotations are now returned in one entity that now includes the timeEnd property.
|
||
|
|
|
||
|
8 years ago
|
## Create Annotation
|
||
|
|
|
||
|
6 years ago
|
Creates an annotation in the Grafana database. The `dashboardId` and `panelId` fields are optional.
|
||
|
4 years ago
|
If they are not specified then an organization annotation is created and can be queried in any dashboard that adds
|
||
|
4 years ago
|
the Grafana annotations data source. When creating a region annotation include the timeEnd property.
|
||
|
5 years ago
|
|
||
|
4 years ago
|
The format for `time` and `timeEnd` should be epoch numbers in millisecond resolution.
|
||
|
8 years ago
|
|
||
|
|
`POST /api/annotations`
|
||
|
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ------------------ | ----------------------- |
|
||
|
|
| annotations:create | annotations:type:<type> |
|
||
|
|
|
||
|
8 years ago
|
**Example Request**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
8 years ago
|
POST /api/annotations HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
4 years ago
|
"dashboardUID":"jcIIG-07z",
|
||
|
8 years ago
|
"panelId":1,
|
||
|
|
"time":1507037197339,
|
||
|
|
"timeEnd":1507180805056,
|
||
|
|
"tags":["tag1","tag2"],
|
||
|
|
"text":"Annotation Description"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Example Response**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
8 years ago
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
8 years ago
|
{
|
||
|
|
"message":"Annotation added",
|
||
|
|
"id": 1,
|
||
|
|
}
|
||
|
8 years ago
|
```
|
||
|
|
|
||
|
6 years ago
|
> The response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would
|
||
|
4 years ago
|
> also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time and
|
||
|
|
> timeEnd properties.
|
||
|
6 years ago
|
|
||
|
8 years ago
|
## Create Annotation in Graphite format
|
||
|
|
|
||
|
|
Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation's timestamp. The `tags` field can also be in prior to Graphite `0.10.0`
|
||
|
|
format (string with multiple tags being separated by a space).
|
||
|
|
|
||
|
|
`POST /api/annotations/graphite`
|
||
|
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ------------------ | ----------------------------- |
|
||
|
|
| annotations:create | annotations:type:organization |
|
||
|
|
|
||
|
8 years ago
|
**Example Request**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
8 years ago
|
POST /api/annotations/graphite HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"what": "Event - deploy",
|
||
|
|
"tags": ["deploy", "production"],
|
||
|
|
"when": 1467844481,
|
||
|
|
"data": "deploy of master branch happened at Wed Jul 6 22:34:41 UTC 2016"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Example Response**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
8 years ago
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
8 years ago
|
{
|
||
|
|
"message":"Graphite annotation added",
|
||
|
|
"id": 1
|
||
|
|
}
|
||
|
8 years ago
|
```
|
||
|
|
|
||
|
7 years ago
|
## Update Annotation
|
||
|
8 years ago
|
|
||
|
|
`PUT /api/annotations/:id`
|
||
|
|
|
||
|
7 years ago
|
Updates all properties of an annotation that matches the specified id. To only update certain property, consider using the [Patch Annotation](#patch-annotation) operation.
|
||
|
7 years ago
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ----------------- | ----------------------- |
|
||
|
|
| annotations:write | annotations:type:<type> |
|
||
|
|
|
||
|
8 years ago
|
**Example Request**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
8 years ago
|
PUT /api/annotations/1141 HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
7 years ago
|
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
8 years ago
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"time":1507037197339,
|
||
|
|
"timeEnd":1507180805056,
|
||
|
|
"text":"Annotation Description",
|
||
|
|
"tags":["tag3","tag4","tag5"]
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
**Example Response**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"message":"Annotation updated"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Patch Annotation
|
||
|
4 years ago
|
|
||
|
7 years ago
|
> This is available in Grafana 6.0.0-beta2 and above.
|
||
|
7 years ago
|
|
||
|
|
`PATCH /api/annotations/:id`
|
||
|
|
|
||
|
|
Updates one or more properties of an annotation that matches the specified id.
|
||
|
|
|
||
|
6 years ago
|
This operation currently supports updating of the `text`, `tags`, `time` and `timeEnd` properties.
|
||
|
7 years ago
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ----------------- | ----------------------- |
|
||
|
|
| annotations:write | annotations:type:<type> |
|
||
|
|
|
||
|
7 years ago
|
**Example Request**:
|
||
|
|
|
||
|
7 years ago
|
```http
|
||
|
7 years ago
|
PATCH /api/annotations/1145 HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
|
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"text":"New Annotation Description",
|
||
|
|
"tags":["tag6","tag7","tag8"]
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
**Example Response**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"message":"Annotation patched"
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
8 years ago
|
## Delete Annotation By Id
|
||
|
|
|
||
|
8 years ago
|
`DELETE /api/annotations/:id`
|
||
|
8 years ago
|
|
||
|
|
Deletes the annotation that matches the specified id.
|
||
|
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ------------------ | ----------------------- |
|
||
|
|
| annotations:delete | annotations:type:<type> |
|
||
|
|
|
||
|
8 years ago
|
**Example Request**:
|
||
|
|
|
||
|
|
```http
|
||
|
8 years ago
|
DELETE /api/annotations/1 HTTP/1.1
|
||
|
8 years ago
|
Accept: application/json
|
||
|
|
Content-Type: application/json
|
||
|
|
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
|
```
|
||
|
|
|
||
|
|
**Example Response**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
7 years ago
|
{
|
||
|
|
"message":"Annotation deleted"
|
||
|
|
}
|
||
|
6 years ago
|
```
|
||
|
4 years ago
|
|
||
|
|
## Find Annotations Tags
|
||
|
|
|
||
|
|
`GET /api/annotations/tags`
|
||
|
|
|
||
|
|
Find all the event tags created in the annotations.
|
||
|
|
|
||
|
4 years ago
|
#### Required permissions
|
||
|
|
|
||
|
|
See note in the [introduction]({{< ref "#annotations-api" >}}) for an explanation.
|
||
|
|
|
||
|
|
| Action | Scope |
|
||
|
|
| ---------------- | ----- |
|
||
|
|
| annotations:read | N/A |
|
||
|
|
|
||
|
4 years ago
|
**Example Request**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
GET /api/annotations/tags?tag=out HTTP/1.1
|
||
|
|
Accept: application/json
|
||
|
|
Content-Type: application/json
|
||
|
|
Authorization: Basic YWRtaW46YWRtaW4=
|
||
|
|
```
|
||
|
|
|
||
|
|
Query Parameters:
|
||
|
|
|
||
|
|
- `tag`: Optional. A string that you can use to filter tags.
|
||
|
|
- `limit`: Optional. A number, where the default is 100. Max limit for results returned.
|
||
|
|
|
||
|
|
**Example Response**:
|
||
|
|
|
||
|
|
```http
|
||
|
|
HTTP/1.1 200
|
||
|
|
Content-Type: application/json
|
||
|
|
|
||
|
|
{
|
||
|
|
"result": {
|
||
|
|
"tags": [
|
||
|
|
{
|
||
|
|
"tag": "outage",
|
||
|
|
"count": 1
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|