Skip to content

Allow creation of Prometheus-type HTTP integrations in GraphQL

What does this MR do and why?

What:

  • Allows creation of Prometheus-type HTTP integrations in GraphQL by adding a type argument to the HttpIntegrationCreate mutation.

Why:

Knock-on effects (logic added & tested in previous MRs):

  • Multiple prometheus integrations can now be created in premium projects (before this MR, we capped it at 1 active prometheus integration; that'll still be the case for free tier)
  • Prometheus integrations now support custom mappings (logic was added in !120055 (merged), but this MR makes it possible for such integrations to actually exist)
  • Prometheus integrations can now be deleted (before this MR, it was impossible to delete it after creation)

A side note on scope:

  • If we also added the type argument for HttpIntegrationUpdate mutation, the backend is supports switching between integration types (HttpIntegrations::UpdateService). But I don't want to add that complication to the UI at this point, as alert management may imminently be deprecated. I'm opting to exclude that functionality from the API wholly.
  • AlertManagement::HttpIntegration records already exist for all Integrations::Prometheus records and are being used as the SSOT for alert ingestion (see prometheus/alerts/notify_service.rb:91)

How to set up and validate locally

  1. Open graphql explorer in local dev (http://gdk.test:3000/-/graphql-explorer)
  2. Execute the below mutation & variables to see the output result
  3. We want to make sure it works with both the original HTTP integrations and the new Prometheus integrations
Mutation/Variables/Output

Mutation:

mutation createHttpIntegrationEE($projectPath: ID!, $name: String!, $active: Boolean!, $payloadExample: JsonString, $payloadAttributeMappings: [AlertManagementPayloadAlertFieldInput!], $type: AlertManagementIntegrationType) {
  httpIntegrationCreate(
    input: {projectPath: $projectPath, name: $name, active: $active, payloadExample: $payloadExample, payloadAttributeMappings: $payloadAttributeMappings, type: $type}
  ) {
    errors
    integration {
      ...HttpIntegrationItem
      __typename
    }
    __typename
  }
}
fragment HttpIntegrationItem on AlertManagementHttpIntegration {
  ...IntegrationItem
  ...HttpIntegrationPayloadData
  __typename
}
  fragment IntegrationItem on AlertManagementIntegration {
    id
    type
    active
    name
    url
    token
    __typename
  }
    fragment HttpIntegrationPayloadData on AlertManagementHttpIntegration {
      id
      payloadExample
      payloadAttributeMappings {
        fieldName
        path
        type
        label
        __typename
      }
      payloadAlertFields {
        path
        type
        label
        __typename
      }
      __typename
    }

With variables:

{
  "name": "NEW ONE", 
  "active": false, 
  "payloadAttributeMappings": [], 
  "payloadExample": "{}",
  "type": "PROMETHEUS",
  "projectPath": "flightjs/Flight"
}

Output:

{
  "data": {
    "httpIntegrationCreate": {
      "errors": [],
      "integration": {
        "id": "gid://gitlab/AlertManagement::HttpIntegration/96",
        "type": "PROMETHEUS",
        "active": false,
        "name": "NEW ONE",
        "url": "http://gdk.test:3000/flightjs/Flight/alerts/notify/new-one/7b60376dd8ade7ce.json",
        "token": "b4d5312572e27206c0bf3149a57ae425",
        "__typename": "AlertManagementHttpIntegration",
        "payloadExample": "{}",
        "payloadAttributeMappings": [],
        "payloadAlertFields": []
      },
      "__typename": "HttpIntegrationCreatePayload"
    }
  },
  "correlationId": "01JX19R3XH0FSTZA03TAYFEJ0Z"
}

Screenshot_2025-06-05_at_7.46.43_PM

MR acceptance checklist

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

Related issue: #338838 (closed)

Edited by Sarah Yasonik

Merge request reports

Loading