Annotations API - create annotation and add user info (loginname or email)

  • What Grafana version and what operating system are you using?
    version 8.4.3 on Windows10

  • What are you trying to achieve?
    add user data when creating annotation via its API

  • How are you trying to achieve it?
    by adding “login”, “email” and “userId” in the ‘body’ of the POST message along with all other standard key/value pairs. This is all being tested with Postman for now.

  • What happened?
    I get a succesful response, but when queyring the API with a GET command or by checking it in a grafana panel with “annotations”-visualization, I still don’t see the username next to the newly added annotation.

  • What did you expect to happen?
    To get the username, useremail or userlogin next to the annotation just like when you’re adding one manually by clicking on the graph which automatically somehow “records” the userdata along with it.

  • Can you copy/paste the configuration(s) that you are having problems with?
    (userinfo below has been replaced by dummy values. Also, all other headers like host and so on are added automatically by Postman)

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

{
  "dashboardUID":"jcIIG-07z",
  "panelId":4,
  "time":1656420056000,
  "timeEnd":1656420056000,
  "tags":["test1","tag2"],
  "text":"Annotation Description",
  "userId": 0,
  "login": "admin",
  "email": "admin@myserver.com"
}
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

  • Did you follow any online instructions? If so, what is the URL?
    Annotations HTTP API | Grafana documentation

This is so that I can have more insight into who is adding annotations through the API. (let’s just assume in this scenario that I’ll always be able to provide some user info :+1:)
For now, my hack was to add the username as a tag, but I’d rather not use tags as it’s not intended for that purpose.

Hi I wonder if you already solved this?
At this moment I am trying to add the user via “tag”, but it would great if there is an options to add user.

Unfortunately not. I checked the files on github and saw that the userID is accepted, but nothing about email or login. Also when querying the “GET” command I can clearly see my given userID from which I hoped Grafana would fill in the rest automatically when storing with POST, but email and login still return empty.

I’ve just gone ahead with using tags for storing user info…which is ugly and not suitable, but nonetheless the better option for now.