Annotations resources / actions
Example Request:
Query Parameters:
from
: epoch datetime in milliseconds. Optional.to
: epoch datetime in milliseconds. Optional.limit
: number. Optional - default is 100. Max limit for results returned.alertId
: number. Optional. Find annotations for a specified alert.dashboardId
: number. Optional. Find annotations that are scoped to a specific dashboardpanelId
: number. Optional. Find annotations that are scoped to a specific paneluserId
: number. Optional. Find annotations created by a specific usertype
: string. Optional.alert
|annotation
Return alerts or user created annotationstags
: string. Optional. Use this to filter global annotations. Global 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
.
Example Response:
HTTP/1.1 200
Content-Type: application/json
[
{
"id": 1124,
"alertId": 0,
"dashboardId": 468,
"panelId": 2,
"userId": 1,
"userName": "",
"newState": "",
"prevState": "",
"time": 1507266395000,
"timeEnd": 1507266395000,
"text": "test",
"metric": "",
"tags": [
"tag1",
"tag2"
],
"data": {}
},
{
"id": 1123,
"alertId": 0,
"dashboardId": 468,
"panelId": 2,
"userName": "",
"newState": "",
"prevState": "",
"time": 1507265111000,
"text": "test",
"metric": "",
"tags": [
"tag1",
],
"data": {}
}
]
Create Annotation
Creates an annotation in the Grafana database. The dashboardId
and panelId
fields are optional. If they are not specified then a global annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation include the timeEnd property.
The format for time
and timeEnd
should be epoch numbers in millisecond resolution.
POST /api/annotations
Example Request:
POST /api/annotations HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"dashboardId":468,
"panelId":1,
"time":1507037197339,
"timeEnd":1507180805056,
"tags":["tag1","tag2"],
"text":"Annotation Description"
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"message":"Annotation added",
"id": 1,
}
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
Example Request:
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"message":"Graphite annotation added",
"id": 1
}
Update Annotation
PUT /api/annotations/:id
Updates all properties of an annotation that matches the specified id. To only update certain property, consider using the Patch Annotation operation.
Example Request:
PUT /api/annotations/1141 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
Content-Type: application/json
{
"timeEnd":1507180805056,
"text":"Annotation Description",
"tags":["tag3","tag4","tag5"]
}
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"message":"Annotation updated"
}
PATCH /api/annotations/:id
This operation currently supports updating of the text
, tags
, time
and timeEnd
properties.
Example Request:
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"message":"Annotation patched"
}
Delete Annotation By Id
DELETE /api/annotations/:id
Deletes the annotation that matches the specified id.
Example Request:
DELETE /api/annotations/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"message":"Annotation deleted"
}
GET /api/annotations/tags
Find all the event tags created in the annotations.
Example Request:
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/1.1 200
Content-Type: application/json
{
"result": {
"tags": [
{
"tag": "outage",
"count": 1
}
]
}
}