Skip to content

Draft: Expose prometheus-type HTTP alert integrations in GraphQL

What does this MR do and why?

Related issue: Allow Prometheus' metrics dashboard and incomin... (#338838)

Category:Metrics features were removed in %16.0. This includes the removal of Integrations::Prometheus - except for the ability to ingest alerts from prometheus instances. The alerting portion is being relocated to AlertManagement::HttpIntegration. This MR contains one piece of that relocation. See the implementation plan for details.

There is no UI impact for this MR.

Changes:

  • Updates graphql HttpIntegrationType to reference the type_identifier field rather than using a static value
  • Allows querying by type on Project.alertManagementHttpIntegrations collection field

New database queries

Triggered by querying Project.alertManagementHttpIntegrations with types argument set to either [] or [HTTP, PROMETHEUS].

SELECT "alert_management_http_integrations".* FROM "alert_management_http_integrations" 
WHERE "alert_management_http_integrations"."project_id" = 6 
ORDER BY "alert_management_http_integrations"."id" DESC 
LIMIT 101

Query plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/23092/commands/74356 (using project_id 14986497)

How to set up and validate locally

  1. Open graphql explorer
  2. Add prometheus/generic http integrations
Mutation to create prometheus integration
mutation prometheusIntegrationCreate {
  prometheusIntegrationCreate(input: {
    projectPath: "flightjs/Flight",
    active: true
  })  {
    integration {
      id
      type
    }
    errors
  }
}
Mutation to create generic HTTP integrations
mutation httpIntegrationCreate {
  httpIntegrationCreate(input: {
    projectPath: "flightjs/Flight",
    active: true,
    name: "Generic HTTP Integration"
  })  {
    integration {
      id
      type
    }
    errors
  }
}
  1. Query Project.alertManagementHttpIntegrations with different type arg values
Query to fetch Alert Integrations
query	fetchAlertManagementHttpIntegrations {
  flight2: project(fullPath: "flightjs/Flight") {
    two: alertManagementHttpIntegrations(types: [HTTP, PROMETHEUS]) {
      nodes {
        id
        name
        type
        url
      }
    }
  }
}
  1. Open http://gdk.test:3000/flightjs/Flight/-/settings/operations, expand Alerts ( flightjs/Flight > Settings > Monitor > Alerts )
    • This should show 1 Prometheus integration & however many HTTP integrations you created

Screenshot_2023-10-12_at_12.59.40_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.

Edited by Sarah Yasonik

Merge request reports