You can send alert notifications to a custom webhook URL when you create a notification policy. The alert management feature in Application Real-Time Monitoring Service (ARMS) lets you send alerts to third-party services by using a webhook. This topic uses Lark as an example to show you how to set up a webhook to receive these notifications.
Step 1: Get a Lark webhook URL
Configure a Lark webhook bot from the Lark desktop client.
Open and log in to Lark.
Click the + icon, and then click New group to create a group for receiving alerts.
Click the group settings icon, and then click the Bots tab.
On the Bots tab, click Add Bot.
In the Add Bot panel, select Custom Bot.
On the configuration page, set the Bot name and Description, and then click Add.
In the resulting section, click Copy to save the webhook URL, and then click Complete.
In the Security Settings section, select the Custom Keywords checkbox and enter the keyword alert in the text box.
Step 2: Create a webhook
-
Log on to the ARMS console. In the left-side navigation pane, choose .
Click the Webhook Integration tab, and then click Create Webhook.
In the Create Webhook dialog box, configure the following parameters.
Parameter
Description
Webhook name
Required. A custom name for the webhook.
Post/Get
Required. The HTTP method. The URL cannot exceed 256 characters.
In this example, select Post and paste the webhook URL that you obtained in Step 1: Get a webhook URL from Lark into the text box on the right.
Header and Param
Optional. Specifies the request header, which cannot exceed 200 characters. Click +Add to add other Headers or Params. The default request header is Content-Type: text/plain; charset=UTF-8, and the total number of Headers and Params cannot exceed 6.
In this example, set the following two Headers:
Arms-Content-Type : json
Content-Type : application/json
Notification template
Optional. The template for notifications sent when an alert is triggered. This parameter is available only for the Post method. You can use the
$contentplaceholder to include the notification content. The template cannot exceed 500 characters. For more information, see Configure a notification template and a webhook template.{ "Alert Name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster Name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application Name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notification Policy":"{{ .dispatchRuleName }}", "Alert Time":"{{ .startTime }}", "Alert Content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }For Lark, you can use the following text format:
{ "msg_type": "text", "content": { "text": "Alert Name: {{ .commonLabels.alertname }}\n{{if .commonLabels.clustername }}Cluster Name: {{ .commonLabels.clustername }}\n{{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}Application Name: {{ .commonLabels._aliyun_arms_involvedObject_name }}\n{{ end }}Notification Policy: {{ .dispatchRuleName }} \nAlert Time: {{ .startTime }} \nAlert Content: {{ for .alerts }} {{ .annotations.message }}\n {{ end }}" } }Template to Clear Alerts
Optional. The template for notifications sent when an alert is cleared. This parameter is available only for the Post method. You can use the
$contentplaceholder to include the notification content. The template cannot exceed 500 characters. For more information, see Configure a notification template and a webhook template.{ "Alert Name":"{{ .commonLabels.alertname }}{{if .commonLabels.clustername }}", "Cluster Name":"{{ .commonLabels.clustername }} {{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}", "Application Name":"{{ .commonLabels._aliyun_arms_involvedObject_name }} {{ end }}", "Notification Policy":"{{ .dispatchRuleName }}", "Recovery Time":"{{ .endTime }}", "Alert Content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }For Lark, you can use the following text format:
{ "msg_type": "text", "content": { "text": "Alert Name: {{ .commonLabels.alertname }}\n{{if .commonLabels.clustername }}Cluster Name: {{ .commonLabels.clustername }}\n{{ end }}{{if eq "app" .commonLabels._aliyun_arms_involvedObject_kind }}Application Name: {{ .commonLabels._aliyun_arms_involvedObject_name }}\n{{ end }}Recovery Time: {{ .startTime }} \nNotification Policy: {{ .dispatchRuleName }} \nCleared Alert Content: {{ for .alerts }} {{ .annotations.message }}\n {{ end }}" } }Optional: Click Send Test to verify the configuration.
Click OK.
Step 3: Configure a notification policy
Create or edit a notification policy. Set Notification Objects to Universal Webhook, and then select the webhook that you created. For more information, see Notification policy.
A webhook request times out if a response is not received within 5 seconds, causing the notification to fail.