Webhook Alert
The Webhook Alert Method enables sending 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 the
button.
- 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 then object is assigned to projectdefault
. - Enter a Display Name.
You can enter a 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-name
). This field is populated automatically when you enter a display name, 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 JSON format. (This functionality is only valid with JSON.)
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 the Add Alert Method
YAML Configurationβ
- YAML
- Example
Hereβs a general specification for adding a Webhook Alert Method through YAML:
apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: # string
displayName: # string
project: # string
spec:
description: # string
webhook:
url: # string
Here's an example of Webhook specification through YAML:
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: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 name | Description |
---|---|
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 |
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 Method in the UIβ
- Navigate to Integrations > Alert Methods.
- Follow the process outlined above to add the Alert Method in the Nobl9 UI: complete the steps in the Create Alert Method wizard, and Click the Add Alert Method
- On the Details screen, click the Test button in the upper-right corner. If the configuration is correct, Nobl9 will display the following message next to the button:
Test completed successfully!
- Navigate to Integrations > Alert Methods.
- Find the Alert Method you want to test in the list, and click it.
- On the Details screen, click the Test button in the upper-right corner.