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 typeargument to theHttpIntegrationCreatemutation.
Why:
- This change enables us to migrate all of the frontend usages of the old prometheus-specific mutations in prometheus_integration/to the generic http integration mutations (http_integration/). That migration will happen in Swap to http integration requests for prometheu... (!193830 - merged).
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 typeargument forHttpIntegrationUpdatemutation, 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::HttpIntegrationrecords already exist for allIntegrations::Prometheusrecords and are being used as the SSOT for alert ingestion (seeprometheus/alerts/notify_service.rb:91)
How to set up and validate locally
- Open graphql explorer in local dev (http://gdk.test:3000/-/graphql-explorer)
- Execute the below mutation & variables to see the output result
- 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"
}MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- 
I have evaluated the MR acceptance checklist for this MR. 
Related issue: #338838 (closed)
Edited  by Sarah Yasonik
