Skip to main content

Webhook alert

Reading time: 0 minute(s) (0 words)

The webhook alert method sends alerts through an HTTP callback handler that is triggered by an event. You can create webhooks and configure them to handle different incident notifications using either custom or predefined notification templates.

Configuring the webhook alert methodโ€‹

You can configure your webhook alert method directly in the Nobl9 UI, or by applying a YAML file in sloctl.

Nobl9 UIโ€‹

To set up the alert method in the Nobl9 UI, follow these steps:

  1. Navigate to Integrations > Alert Methods.
  2. Click .
  3. Click the relevant Alert Method icon.

Then, in the Webhook Configuration Wizard:

  1. Enter the URL (mandatory).
    The URL must start with https://.

  2. Select a Project.
    Specifying a project is helpful when multiple users are spread across multiple teams or projects. When the Project field is left blank, Nobl9 uses the default project.
  3. Enter a Display Name.
    You can enter a user-friendly name with spaces in this field.
  4. Enter a Name.
    The name is mandatory and can only contain lowercase, alphanumeric characters, and dashes (for example, my-alert-method-1). Nobl9 duplicates the display name here, transforming it into the supported format, but you can edit the result.
  5. Enter a Description.
    Here you can add details such as who is responsible for the integration (team/owner) and the purpose of creating it.
  6. The Custom Header field is used to add a customized header. Click the blue plus icon icon to add a header. For example, a custom header named Authorization.

    • The Key can contain alphanumeric characters and dashes, and must start with a letter.
  7. The Notification Details tab allows you to configure a standard Nobl9 webhook or a Custom webhook:

    • A standard Nobl9 webhook lets you choose fields from a checklist which are then sent with the default Nobl9 webhook message. You must select at least one field from the checklist.

    • A Custom webhook lets you create your own payload in the JSON format.1
      1This functionality works with JSON only.

      • Each field name must be enclosed in double quotes ("<field_name>").

      • Most fields are in string format.

      • If the fieldโ€™s value is an array, you must use JSON syntax to define it. The array fields have a special format with square brackets ([]) after the variable name. For example $alert_policy_conditions[].

  8. Click Add alert method.

YAML configurationโ€‹

General YAML sample for Webhook alert method
apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: string # Mandatory
displayName: string # Optional
project: default # Mandatory
spec:
description: string # Optional
webhook:
url: string # Mandatory, must start with https://

Creating webhook custom templates through YAMLโ€‹

The YAML for the webhook integration supports custom notification message templates. The template can be specified in two ways:

  1. Only variables are specified, and the notification message is generated automatically.
    For example, the following YAML specification:

    apiVersion: n9/v1alpha
    kind: AlertMethod
    ...
    spec:
    webhook:
    url: <https://hook.web>
    templateFields:
    - slo_name
    - slo_details_link

    might yield this notification message:

    {
    "slo_name": "Test SLO",
    "slo_details_link": "<https://main.nobl9.dev/slo/details?project=proj1&name=test_slo">
    }
  2. A full message template is specified, with variables in the form $<variable_name>.
    For example, you might have a YAML specification like the following:

    Webhook message template
    apiVersion: n9/v1alpha
    kind: AlertMethod
    metadata:
    displayName: Webhook Custom
    name: webhook-custom
    spec:
    description: ""
    webhook:
    template: |-
    {
    "message": "Your SLO $slo_name needs attention!",
    "timestamp": "$timestamp",
    "severity": "$severity",
    "slo": "$slo_name",
    "project": "$project_name",
    "organization": "$organization",
    "alert_policy": "$alert_policy_name",
    "alerting_conditions": $alert_policy_conditions[],
    "service": "$service_name",
    "labels": {
    "slo": "$slo_labels_text",
    "service": "$service_labels_text",
    "alert_policy": "$alert_policy_labels_text"
    }
    }
    url: '[hidden]'

The following is a list of all supported variables:

Variable nameDescription
alert_idThe ID of the alert.
alert_policy_conditions[]Conditions defined for the alert policy (in a JSON array).
alert_policy_conditions_textConditions defined for the alert policy (string format).
alert_policy_descriptionThe descriptions of the alert policy.
alert_policy_labels_textThe labels attached to the alert policy.
alert_policy_nameThe name of the alert policy to which the alert method is attached.
objective_nameThe name of the objective which triggered this alert policy.
iso_timestampThe timestamp in ISO format when the alert was triggered.
organizationThe name of the Nobl9 Organization to which the alert method is attached.
project_nameThe name of the project to which the alert method is attached.
service_labels_textLabels attached to the service to which the alert method is attached.
service_nameThe name of the service to which the alert method is attached.
severitySeverity attached to your alert policy (high| medium | low).
slo_details_linkA link to the service level objective to which the alert method is attached.
slo_labels_textLabels attached to the SLO to which the alert method is attached.
slo_nameThe name of the SLO to which the alert method is attached.
timestampThe timestamp indicating when the alert was triggered.

Important notes:

  • The Webhook integration definition requires one (and only one) of these entries:

    • spec.webhook.template

    • spec.webhook.templateFields

  • The difference between alert_policy_conditions[] and alert_policy_conditions_text is that alert_policy_conditions[] creates a valid JSON array of conditions as strings, whereas alert_policy_conditions_text creates a single string field. For example:

    {
    "text": "Remaining error budget is 10%, Error budget would be exhausted in 15 minutes and this condition lasts for 1 hour",
    "array": [
    "Remaining error budget is 10%",
    "Error budget would be exhausted in 15 minutes and this condition lasts for 1 hour"
    ]
    }
  • slo_labels_text, service_labels_text, and alert_policy_labels_text are comma-separated key:value pairs. For example:

    • slo:ratio, slo:calendar

    • project:myproject

    • alert:low, alert:high

Testing the webhook alert policy in the UIโ€‹

You can test alert methods for all notification services supported by the Nobl9 platform through the UI.

To verify the correctness of your alert method configuration:

  1. Navigate to Integrations > Alert Methods.
  2. Click the required alert method.
    Its Details page opens.
  3. Click Test under the alert method name:
    • For the correct configuration, Nobl9 displays Test completed successfully! under the button
    • Otherwise, Nobl9 displays the Test failed message, specifying what is set incorrectly
For a more in-depth look, consult additional resources: