Skip to content

Add GraphQL mutation to link alerts to incidents

Vitali Tatarintev requested to merge 103364-link-alerts-to-incident-graphql into master

What does this MR do and why?

Adds a GraphQL mutation to link alerts to incidents by providing alert references.

Contributes to #356057 (closed)

GraphQL mutation examples

Issue query

query Issue {
  issue(id:"gid://gitlab/Issue/441") {
    id
    title
    alertManagementAlerts {
      nodes {
        title
      }
    }
  }
}

Response example

{
  "data": {
    "issue": {
      "id": "gid://gitlab/Issue/441",
      "title": "Testing linking alerts",
      "alertManagementAlerts": {
        "nodes": []
      }
    }
  }
}

Mutation

mutation IssueLinkAlerts($input: IssueLinkAlertsInput!) {
  issueLinkAlerts(input: $input) {
    issue {
      iid
      alertManagementAlerts {
        nodes {
          iid
          title
        }
      }
    }
  }
}

Query variables

{
  "input":{
    "projectPath": "ck3g/playground",
    "iid": "4",
    "alertReferences": ["^alert#1", "http://127.0.0.1:3000/ck3g/playground/-/alert_management/2/details"]
  }
}

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Make sure to have developer (or above) permissions in your project
  2. Make sure to have alerts HTTP integration configured for your project under Settings > Monitor > Alerts
  3. Make sure to have existing alerts (they can be created from the integration settings)
  4. Navigate to GraphiQL explorer (for example http://127.0.0.1:3000/-/graphql-explorer)
  5. Use query and mutation from above with your project path, issue, and alert IDs.

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 Vitali Tatarintev

Merge request reports