Webhook alert
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:
- Navigate to Integrations > Alert Methods.
- Click .
- Click the relevant Alert Method icon.
Then, in the Webhook Configuration Wizard:
-
Enter the URL (mandatory).
The URL must start withhttps://
. -
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 thedefault
project. -
Enter a Display Name.
You can enter a user-friendly name with spaces in this field. -
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. -
Enter a Description.
Here you can add details such as who is responsible for the integration (team/owner) and the purpose of creating it. -
The Custom Header field is used to add a customized header. Click the 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.
-
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[]
.
-
-
- Click Add alert method
YAML configurationโ
- YAML
- Example
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://
apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: webhook-notification
displayName: Webhook notification
project: default
spec:
description: Sends HTTP request to custom webhook
webhook:
url: <https://sample-end-point/notify>
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:
-
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_linkmight yield this notification message:
{
"slo_name": "Test SLO",
"slo_details_link": "<https://main.nobl9.dev/slo/details?project=proj1&name=test_slo">
} -
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 templateapiVersion: 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 name | Description |
---|---|
alert_id | The ID of the alert. |
alert_policy_conditions[] | Conditions defined for the alert policy (in a JSON array). |
alert_policy_conditions_text | Conditions defined for the alert policy (string format). |
alert_policy_description | The descriptions of the alert policy. |
alert_policy_labels_text | The labels attached to the alert policy. |
alert_policy_name | The name of the alert policy to which the alert method is attached. |
objective_name | The name of the objective which triggered this alert policy. |
iso_timestamp | The timestamp in ISO format when the alert was triggered. |
organization | The name of the Nobl9 Organization to which the alert method is attached. |
project_name | The name of the project to which the alert method is attached. |
service_labels_text | Labels attached to the service to which the alert method is attached. |
service_name | The name of the service to which the alert method is attached. |
severity | Severity attached to your alert policy (high | medium | low ). |
slo_details_link | A link to the service level objective to which the alert method is attached. |
slo_labels_text | Labels attached to the SLO to which the alert method is attached. |
slo_name | The name of the SLO to which the alert method is attached. |
timestamp | The 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[]
andalert_policy_conditions_text
is thatalert_policy_conditions[]
creates a valid JSON array of conditions as strings, whereasalert_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
, andalert_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โ
- Navigate to Integrations > Alert Methods.
- Click the required alert method.
Its Details page opens. - 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