Skip to content

Backend: Expose an endpoint to fetch all annotations

Problem to solve

The annotations model implemented in #211329 (closed) should be accessible via API so that the frontend can hit to perform basic read operations.

More information about the technical break down here #205091 (comment 302202307)

Technical details

PoC available here: !27675 (closed)

This API will be a GraphQL API.

Based on the model here https://gitlab.com/gitlab-org/gitlab/-/issues/211329#annotation-model, annotations are associated with panel Id, cluster Id, dashboard Id.

Query

query {
  project(fullPath: "monitoring-group/docker-app-clone") {
    id
    environment(name: "production") {
      id
      name
      metricsDashboard (id: "custom_dashboard.yml") {
        id
        annotations {
          nodes {
            id
            description
            from
            to
            panelId
          }
     	}
      }
    }
  }
}

Response:

{
  "data": {
    "project": {
      "id": "gid://gitlab/Project/28",
      "environment": {
        "id": "gid://gitlab/Environment/34",
        "name": "production",
        "metricsDashboard": {
          "id": "gid://custom_dashboard.yml",
          "annotations": {
            "nodes": [
              {
                "id": "gid://gitlab/Annotations/1",
                "description": "annotation description",
                "from": "2020-03-20 13:50:07",
                "to": null,
                "panelId": null
              },
              {
                "id": "gid://gitlab/Annotations/2",
                "description": "annotation description",
                "from": "2020-03-20 13:50:07",
                "to": null,
                "panelId": "some-panel-id"
              }
            ]
          }
        }
      }
    }
  }
}
Edited by 🤖 GitLab Bot 🤖