0

I'm trying to create an annotation in Grafana via the HTTP-API.

Due to the official docs I need to add a timestamp.

Example Request (from official docs)

POST /api/annotations HTTP/1.1
Accept: application/json
Content-Type: application/json

{
  "dashboardId":468,
  "panelId":1,
  "time":1507037197339,
  "isRegion":true,
  "timeEnd":1507180805056,
  "tags":["tag1","tag2"],
  "text":"Annotation Description"
}

But what kind of timestamp is it? I couldn't find any information about it.

I tested it with the current unix timestamp but the annotation will not show up.

Maybe helpful: My last alert from yesterday (13. Dez 2017, 07:02PM UTC+1) corresponds to "time": 1513101762000,.

Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69

1 Answers1

1

Time should be in epoch in milliseconds based on their docs from the find method:

Query Parameters: from: epoch datetime in milliseconds. Optional. to: epoch datetime in milliseconds. Optional.

Check here for some code examples: http://currentmillis.com/

Also, if you don't see them showing up on your dashboard be sure to use the header token authentication against the API and make sure you created the token API for the same org that the dashboard lives under.

A curl request would look similar too: curl -i -XPOST -H "Authorization: Bearer <token>" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"time":1513187523781,"isRegion":false,"tags":["test1"],"text":"Testing Annotations API"}' "https://grafana.host/api/annotations"

DaLord
  • 149
  • 5