Skip to content

Add Metrics Dashboard GraphQL alert queries to FF

Sarah Yasonik requested to merge sy-flag-metrics-dashboard-graphql-queries into master

What does this MR do and why?

This MR gates the metrics dashboard graphql alert queries behind the remove_monitor_metrics feature flag. The frontend feature that used this field was actually removed a very long time ago. 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 an environment

  1. Create a prometheus alert with the right attributes via the rails console
    environment = Environment.last
    project = environment.project
    payload = JSON.parse({
      "labels": {
        "gitlab_environment_name": environment.name
      },
      "status": "firing",
      "startsAt": "2021-03-17T11:22:40Z",
      "annotations": {
        "title": "Testing that prometheus alerts do not re-acknowledge",
        "gitlab_y_label": "status"
      },
      "generatorURL": "http://host?g0.expr=up"
    }.to_json)
    
    AlertManagement::ProcessPrometheusAlertService.new(project, payload).execute
  2. Use http://gdk.test:3000/-/graphql-explorer to query for alert details
Query Response before Response after
query alerts {
  project(fullPath: "namespace1/project-1") {
    alertManagementAlerts {
      nodes {
        id
        title
        metricsDashboardUrl
      }
    }
  }
}
{
  "data": {
    "project": {
      "alertManagementAlerts": {
        "nodes": [
          {
            "id": "gid://gitlab/AlertManagement::Alert/7",
            "title": "Testing that prometheus alerts do not re-acknowledge",
            "metricsDashboardUrl": "http://gdk.test:3000/namespace1/project-1/-/environments/1/metrics_dashboard?embed_json=%7B%22panel_groups%22%3A%5B%7B%22panels%22%3A%5B%7B%22type%22%3A%22area-chart%22%2C%22title%22%3A%22Testing+that+prometheus+alerts+do+not+re-acknowledge%22%2C%22y_label%22%3A%22status%22%2C%22metrics%22%3A%5B%7B%22query_range%22%3A%22up%22%7D%5D%7D%5D%7D%5D%7D&embedded=true&end=2021-03-17T11%3A52%3A40Z&start=2021-03-17T10%3A52%3A40Z"
          }
        ]
      }
    }
  }
}
{
  "data": {
    "project": {
      "alertManagementAlerts": {
        "nodes": [
          {
            "id": "gid://gitlab/AlertManagement::Alert/7",
            "title": "Testing that prometheus alerts do not re-acknowledge",
            "metricsDashboardUrl": null
          }
        ]
      }
    }
  }
}

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 Sarah Yasonik

Merge request reports