Webhook alert method
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 Web
To set up the alert method on the Nobl9 Web, follow these steps:
- Navigate to Integrations > Alert methods.
- Click
.
- Select Webhook.
-
Enter the URL (mandatory).
Your webhook endpoint HTTP POST requests will be sent to.
The URL must start withhttps://
. -
Select a Project.
Project is a way to organize your Nobl9 resources and manage access to them.
When Project is skipped, 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. -
You can add Description to your resource, providing extra details about it, its purpose, responsible persons, etc.
Up to 1050 characters. -
In the Custom Header block, you can add customized headers to be sent along with Webhook notifications. To add a custom header:
- Click
.
- Enter Key and Value
- For Key, use only letters, numbers, hyphens (-), and underscores (_). It must start with a letter or number.
- Click
-
Configure Notification Details to define the details to be included in the response payload. Select between the following options:
-
Nobl9: select at least one field from the list of predefined details.
-
Custom: create a custom payload or click Insert to use templated field values. Only JSON is accepted:
- Enclose each field name in double quotes (
"<field_name>"
) - Indicate variables with
$
, use lowercase letters, and separate words with_
- When you expect to receive an array, add square brackets (
[]
) after the value
For example{
"policy": $alert_policy_conditions[],
"message": "Your SLO $slo_name needs attention!"
} - Enclose each field name in double quotes (
-
- Click Add alert method
YAML configuration
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
- A full message template is specified, with variables in the form
$<variable_name>
- YAML
- Example with variables
- Full message template example
apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: string # Mandatory
displayName: string # Optional
project: default # Mandatory
# Optional
# The key value: only alphanumeric characters, `-`, `_`, or `.` are allowed.
# The key value must start and end with an alphanumeric character.
# An optional DNS subdomain prefix followed by `/` is allowed.
annotations:
key: value
spec:
description: string # Optional
webhook:
url: string # Mandatory, must start with https://
# Either `templateFields` or `template` must be specified, but not both.
templateFields: # array of strings
- string1
- string2
# Replace the `templateFields` with `template` if a full template is used
# template: string
# Webhook Alert Method with template
- apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: webhook
displayName: Webhook Alert Method
project: default
annotations:
area: latency
env: prod
region: us
team: sales
spec:
description: Example Webhook Alert Method
webhook:
url: https://123.execute-api.eu-central-1.amazonaws.com/default/putReq2S3
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"
}
}
headers:
- name: Authorization
value: very-secret
isSecret: true
- name: X-User-Data
value: "{\"data\":\"is here\"}"
isSecret: false
# Webhook Alert Method with templateFields
- apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: webhook
displayName: Webhook Alert Method
project: default
annotations:
area: latency
env: prod
region: us
team: sales
spec:
description: Example Webhook Alert Method
webhook:
url: https://123.execute-api.eu-central-1.amazonaws.com/default/putReq2S3
templateFields:
- project_name
- service_name
- organization
- alert_policy_name
- alert_policy_description
- alert_policy_conditions[]
- alert_policy_conditions_text
- severity
- slo_name
- objective_name
- timestamp
- no_data_alert_after
- anomaly_type
headers:
- name: Authorization
value: very-secret
isSecret: true
- name: X-User-Data
value: "{\"data\":\"is here\"}"
isSecret: false
This configuration yields a notification message like:
{
"slo_name": "Test SLO",
"slo_details_link": "<https://main.nobl9.dev/slo/details?project=proj1&name=test_slo">
}
- apiVersion: n9/v1alpha
kind: AlertMethod
metadata:
name: webhook
displayName: Webhook Alert Method
project: default
annotations:
area: latency
env: prod
region: us
team: sales
spec:
description: Example Webhook Alert Method
webhook:
url: https://123.execute-api.eu-central-1.amazonaws.com/default/putReq2S3
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"
},
"no_data_alert_after": "$no_data_alert_after",
"anomaly_type": "$anomaly_type"
}
headers:
- name: Authorization
value: very-secret
isSecret: true
- name: X-User-Data
value: "{\"data\":\"is here\"}"
isSecret: false
The supported variables are as follows:
Variable name | Description |
---|---|
alert_id | Unique identifier of the alert |
alert_policy_conditions[] | Conditions defined for the alert policy that uses this alert method (JSON format) |
alert_policy_conditions_text | Conditions of the associated alert policy (string format) |
alert_policy_description | Description of the associated alert policy |
alert_policy_labels_text | Labels attached to the associated alert policy |
alert_policy_name | Name identifier of the alert policy that triggered the alert |
anomaly_type | Type of anomaly. The noData type is returned, indicating that the SLO reports no data for 15 minutes |
objective_name | Name identifier of the SLO objective that triggered the alert |
iso_timestamp | Timestamp (ISO format) when the alert was triggered |
no_data_alert_after | The interval Nobl9 waits for missing data from an SLO before alerting on no data Currently, this interval is fixed at 15m |
organization | Name identifier of the Nobl9 organization where the alert was triggered |
project_name | Name identifier of the project associated with this alert method |
service_labels_text | Labels attached to the service holding the SLO that triggered the alert |
service_name | Name identifier of the associated service |
severity | Severity level of the alert policy (high , medium , or low ) |
slo_details_link | Link to the SLO that triggered the alert |
slo_labels_text | Labels attached to the associated SLO |
slo_name | Name identifier of the SLO that triggered the alert |
timestamp | Timestamp when the alert was triggered |
Important notes:
-
In your Webhook YAML definition, define either of the following objects:
-
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:
- When the configuration is correct, Nobl9 displays Test completed successfully! under the button.
- Otherwise, the Test failed message appears. It contains the details of incorrect settings.