Creating and Updating Alert Sources

Use OpsLevel's API to create and update Alert Sources for any alerting tool.

OpsLevel automatically creates Alert Sources through our native integrations with the most common alerting tools, including Datadog, PagerDuty, incident.io, FireHydrant , and others. If you want to create your own Alert Sources from any tool, you can use the Alert Source API.

Adding an Alert Source

All Alert Sources sent via API must be connected to a Custom Integration

To create an Alert Source in the OpsLevel API, you can use the command below.

mutation($input: AlertSourceInput!) {
  alertSourceUpsert(input: $input) {
    alertSource {
      id
      name
      externalId
      url
      description
      type
      integration {
        id
        plainId
      }
    }
    errors {
      message
    }
  }
}

# Variables
{
  "input": {
    "identifier": {
          "integration": { "id": "abcdef" },
          "externalId": "alert-source-3"
        },
        "name": "Registration"
  }
}

Linking and unlinking Alert Sources to Components

When a new Alert Source is created, we will attempt to automatically link it based on Component data. If we are unable to automatically link the Alert Source to a component, we'll create a Suggestion. You can also manually link and unlink Alert Sources from a Component via the UI or API.

To link via the API, you can use this command:

mutation($service: IdentifierInput!, $alertSourceId: ID, $alertSourceExternalIdentifier: AlertSourceExternalIdentifier) {
        alertSourceServiceCreate(input: {
          service: $service, alertSourceId: $alertSourceId, alertSourceExternalIdentifier: $alertSourceExternalIdentifier
        }) {
    alertSourceService {
      alertSource {
        id
        name
        type
      }
      id
      status
      service {
        id
        name
      }
    }
    errors {
      message
      path
    }
  }
}

# Variables
{ 
  service: { alias: "service-aliast" }, 
  alertSourceId: "alert-source-gid"
}

To unlink, use this command:

mutation($id: ID!) {
  alertSourceServiceDelete(input: { id: $id }) {
    deletedAlertSourceServiceId
    errors {
      message
      path
    }
  }
}

# Variables
{ id: "base64_gid_alert_source_service" }

Updating Alert Source status

Updating an Alert Source status will update its status on all connected services.

mutation($input: AlertSourceStatusUpdateInput!) {
  alertSourceStatusUpdate(input: $input) {
    alertSource {
      id
      name
      alertSourceServices(first: 10) {
        edges {
          node {
            id
            status
          }
        }
      }
    }
    errors {
      message
    }
  }
}
# Variables
{
  "input":  {
        "alertSource": {
          "integration": { "id": "abcdefg" },
          "externalId": "alert-source-3"
        },
        "status": "ok"
      }
}

Destroying an Alert Source

To delete an Alert Source, use this command:

mutation($input: ExternalResourceIdentifierInput!) {
  alertSourceDelete(input: $input) {
    deletedId
    deletedAlias
    errors {
      message
      path
    }
  }
}
# Variables
{
 "input":  {
        "alertSource": {
          "integration": { "id": "abcdefg" },
          "externalId": "alert-source-3"
        }
}