Skip to content

Add Metrics Dashboard annnotations API to FF

What does this MR do and why?

This MR gates the metrics dashboard annotations API behind the remove_monitor_metrics feature flag. Frontend is done, but we also want to deprecate/remove any API access.

Related issue: Metrics: Delete API entrypoints & helpers (#397138 - closed) (one of many MRs)

Context for removal:

All related backend MRs to flag all metrics dashboard endpoints

How to set up and validate locally

Pre-req: Project with environments

  1. Use graphiql to test the query -> http://gdk.test:3000/-/graphql-explorer
  2. We can verify the flag without annotations actually set up, because the response attribute will switch from [] to null or error
Query Response before Response after
query annotations {
  project(fullPath: "gitlab-org/monitor/monitor-sandbox") {
    environments {
      nodes {
        metricsDashboard(path: "config/prometheus/common_metrics.yml") {
          annotations(from: "2023-05-09 11:57:31 -0400", to: "2023-05-10 11:57:31 -0400") {
            nodes {
              id
              panelId
              description
            }
          }
        }
      }
    }
  }
}
{
  "data": {
    "project": {
      "environments": {
        "nodes": [
          {
            "metricsDashboard": {
              "annotations": {
                "nodes": []
              }
            }
          }
        ]
      }
    }
  }
}
{
  "data": {
    "project": {
      "environments": {
        "nodes": [
          {
            "metricsDashboard": {
              "annotations": null
            }
          }
        ]
      }
    }
  }
}
mutation otherannotations {
  createAnnotation(
    input: { 
      environmentId: "gid://gitlab/Environment/1",  
      dashboardPath: "config/prometheus/common_metrics.yml", 
      startingAt: "2023-05-09 11:57:31 -0400", 
      description: "Something happened!"
    }
  ) {
    annotation {
      id
      description
    }
  }
}
{
  "data": {
    "createAnnotation": {
      "annotation": {
        "id": "gid://gitlab/Metrics::Dashboard::Annotation/1",
        "description": "Something happened!"
      }
    }
  }
}
{
  "data": {
    "createAnnotation": null
  },
  "errors": [
    {
      "message": "The resource that you are attempting to access does not exist or you don't have permission to perform this action",
      "locations": [
        {
          "line": 21,
          "column": 3
        }
      ],
      "path": [
        "createAnnotation"
      ]
    }
  ]
}
mutation deleteannotations {
  deleteAnnotation(input: { id: "gid://gitlab/Metrics::Dashboard::Annotation/2" }) {
    errors
  }
}
{
  "data": {
    "deleteAnnotation": {
      "errors": []
    }
  }
}
{
  "data": {
    "deleteAnnotation": null
  },
  "errors": [
    {
      "message": "The resource that you are attempting to access does not exist or you don't have permission to perform this action",
      "locations": [
        {
          "line": 37,
          "column": 3
        }
      ],
      "path": [
        "deleteAnnotation"
      ]
    }
  ]
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports

Loading