Skip to content

Add GraphQL query for alert integrations

Sarah Yasonik requested to merge sy-read-all-integrations into master

What does this MR do?

Issue: #255515 (closed), partially #255603 (closed)

Adds a GraphQL query to expose alerting integrations. This query is intended to be used to populate the integrations table at project > Settings > Operations > Alerts.

The return type of the query is AlertManagementIntegration, which can be either an AlertManagementHttpIntegration or AlertManagementPrometheusIntegration.

HTTP Integrations are backed by the AlertManagement::HttpIntegration model. Prometheus Integrations are backed by a combination of ::PrometheusService and ::Alerting::ProjectAlertingSetting. For reference on the attributes exposed for prometheus integrations today, see OperationsHelper.

Sample usage

query integrations {
  project(fullPath: "root/autodevops") {
    alertManagementIntegrations {
      nodes {
        id
        type
        active
        name
        url
        token
        apiUrl
      }
    }
  }
}

Sample output

{
  "data": {
    "project": {
      "alertManagementIntegrations": {
        "nodes": [
          {
            "id": "gid://gitlab/AlertManagement::HttpIntegration/7",
            "type": "HTTP",
            "active": true,
            "name": "test",
            "url": "http://192.168.1.152:3000/root/autodevops/alerts/notify/test/eddd36969b2d3d6a.json",
            "token": "7eb24af194116411ec8d66b58c6b0d2e",
            "apiUrl": null
          },
          {
            "id": "gid://gitlab/AlertManagement::HttpIntegration/6",
            "type": "HTTP",
            "active": false,
            "name": "test",
            "url": "http://192.168.1.152:3000/root/autodevops/alerts/notify/test/abce123.json",
            "token": "8639e0ce06c731b00ee3e8dcdfd14fe0",
            "apiUrl": null
          },
          {
            "id": "gid://gitlab/AlertManagement::HttpIntegration/5",
            "type": "HTTP",
            "active": false,
            "name": "test",
            "url": "http://192.168.1.152:3000/root/autodevops/alerts/notify/test/bcd64c85f918a2e2.json",
            "token": "5c8101533d970a55d5c105f8abff2192",
            "apiUrl": null
          },
          {
            "id": "gid://gitlab/PrometheusService/12",
            "type": "PROMETHEUS",
            "active": true,
            "name": "Prometheus",
            "url": "http://192.168.1.152:3000/root/autodevops/prometheus/alerts/notify.json",
            "token": "0b18c37caa8fe980799b349916fe5ddf",
            "apiUrl": "https://another-url-2.com"
          }
        ]
      }
    }
  }
}

Sibling MRs:

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Mayra Cabrera

Merge request reports