Deprecate all prometheus integration mutations and always return http integrations instead

What does this MR do and why?

As of Allow Prometheus' metrics dashboard and incomin... (#338838 - closed), we have fully consolidated generic alerting integrations and Prometheus-specific integrations into one model.

Updates to Integrations::Prometheus records are currently being synced to a corresponding AlertManagement::HttpIntegration. This MR updates the prometheus-specific mutations to make updates directly on the corresponding AlertManagement::HttpIntegration.

This MR:

  • deprecates all queries and mutations using the AlertManagementPrometheusIntegration type
  • replaces any return values with the corresponding AlertManagementHttpIntegration type

References

How to set up and validate locally

Pre-req: a project with a legacy prometheus integration

  1. Find a project without a prometheus integration
    • Project.ids.sort - Integrations::Prometheus.pluck(:project_id)
  2. Create legacy prometheus integration for that project
    • Integrations::Prometheus.create!(project_id: 64, manual_configuration: true)
  3. Initialize token for the integration
    • Alerting::ProjectAlertingSetting.create!(project_id: 64)
  4. There should also now be an alerting integration for the project
    • AlertManagement::HttpIntegration.find_by(project_id: 64, type_identifier: :prometheus)

Testing graphql changes

Executing from http://gdk.test:3000/-/graphql-explorer:

Query alertManagementIntegrations
query httpintegrations { 
  project(fullPath: "gitlab-qa-product-analytics/product-analytics-g-52f8a073f314e28c/project-analytics-p-bb2c3a2770d54b52-c64ec02d2900d1ed"
") { 
    alertManagementIntegrations {
      nodes {
        id
        type
        name
        active
      }
    }
  }
}

Before

{
  "data": {
    "project": {
      "alertManagementIntegrations": {
        "nodes": [
          {
            "id": "gid://gitlab/AlertManagement::HttpIntegration/261",
            "type": "PROMETHEUS",
            "name": "Prometheus",
            "active": true
          }
        ]
      }
    }
  },
  "correlationId": "01JYFE3J53HHQ1Y2C1NM61GEBS"
}

After

{
  "data": {
    "project": {
      "alertManagementIntegrations": {
        "nodes": [
          {
            "id": "gid://gitlab/Integrations::Prometheus/27",
            "type": "PROMETHEUS",
            "name": "Prometheus",
            "active": true
          }
        ]
      }
    }
  },
  "correlationId": "01JYFE4SZC50CE99XV2NS2JZFR"
}
Query by GID alertManagementIntegrations(id: "")
query httpintegration { 
  project(fullPath: "gitlab-qa-product-analytics/product-analytics-g-52f8a073f314e28c/project-analytics-p-bb2c3a2770d54b52-c64ec02d2900d1ed") { 
    alertManagementIntegrations(id: "gid://gitlab/Integrations::Prometheus/27") {
      nodes {
        id
        type
        name
        active
      }
    }
  }
}

before

{
  "data": {
    "project": {
      "alertManagementIntegrations": {
        "nodes": [
          {
            "id": "gid://gitlab/Integrations::Prometheus/27",
            "type": "PROMETHEUS",
            "name": "Prometheus",
            "active": true
          }
        ]
      }
    }
  },
  "correlationId": "01JYFEEF4QHRPGS2PR2MKR2Q3E"
}

after

{
  "data": {
    "project": {
      "alertManagementIntegrations": {
        "nodes": [
          {
            "id": "gid://gitlab/AlertManagement::HttpIntegration/261",
            "type": "PROMETHEUS",
            "name": "Prometheus",
            "active": true
          }
        ]
      }
    }
  },
  "correlationId": "01JYFEG8X75ZVT89JP8CS5A05K"
}
Create
mutation create($input: PrometheusIntegrationCreateInput!) {
  prometheusIntegrationCreate(input: $input) {
    integration {
      id
      type
      name
      active
    }
    errors 
  }
}
{ 
  "input": {
    "projectPath": "gitlab-qa-product-analytics/product-analytics-g-52f8a073f314e28c/project-analytics-p-bb2c3a2770d54b52-c64ec02d2900d1ed", 
    "active": true
  }
}

Before -- with existing integration

{
  "data": {
    "prometheusIntegrationCreate": {
      "integration": null,
      "errors": [
        "Multiple Prometheus integrations are not supported"
      ]
    }
  },
  "correlationId": "01JYFEVWVCFPBGS4ZS7N6FCA7G"
}

Before -- without existing integration (I'm just using a different project)

{
  "data": {
    "prometheusIntegrationCreate": {
      "integration": {
        "id": "gid://gitlab/Integrations::Prometheus/28",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "active": true
      },
      "errors": []
    }
  },
  "correlationId": "01JYFF06TE69QD69WXK63GG7ED"
}

After

{
  "data": {
    "prometheusIntegrationCreate": {
      "integration": {
        "id": "gid://gitlab/AlertManagement::HttpIntegration/262",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "active": true
      },
      "errors": []
    }
  },
  "correlationId": "01JYFENN8DA2KGH1TQVATT46NR"
}
Update
mutation update($input: PrometheusIntegrationUpdateInput!) {
  prometheusIntegrationUpdate(input: $input) {
    integration {
      id
      type
      name
      active
    }
    errors 
  }
}
{ 
  "input": {
     "id": "gid://gitlab/Integrations::Prometheus/28", 
    "active": false
  }
}

Before

{
  "data": {
    "prometheusIntegrationUpdate": {
      "integration": {
        "id": "gid://gitlab/Integrations::Prometheus/28",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "active": false
      },
      "errors": []
    }
  },
  "correlationId": "01JYFF6X7ANMAQT5T5Z9HS2VME"
}

After

{
  "data": {
    "prometheusIntegrationUpdate": {
      "integration": {
        "id": "gid://gitlab/AlertManagement::HttpIntegration/264",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "active": false
      },
      "errors": []
    }
  },
  "correlationId": "01JYFFA739TSESSQNCZ3S6R8J8"
}
Reset Token
mutation resettoken($input: PrometheusIntegrationResetTokenInput!) {
  prometheusIntegrationResetToken(input: $input) {
    integration {
      id
      type
      name
      token
    }
    errors 
  }
}
{ 
  "input": {
     "id": "gid://gitlab/Integrations::Prometheus/28"
  }
}

before

{
  "data": {
    "prometheusIntegrationResetToken": {
      "integration": {
        "id": "gid://gitlab/Integrations::Prometheus/28",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "token": "e660a94a177c78bc2b0d8c27a535510e"
      },
      "errors": []
    }
  },
  "correlationId": "01JYFFF3QEN7VGA16C5V5V7DCX"
}

after

{
  "data": {
    "prometheusIntegrationResetToken": {
      "integration": {
        "id": "gid://gitlab/AlertManagement::HttpIntegration/264",
        "type": "PROMETHEUS",
        "name": "Prometheus",
        "token": "0b76f068da76fe87a2875bc45e2f420c"
      },
      "errors": []
    }
  },
  "correlationId": "01JYFFDSCSW7V5D8J8P5SYNXVE"
}

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah Yasonik

Merge request reports

Loading