When you create a notification policy, you can specify that alert notifications are sent to a custom webhook URL. The Alert Management module of Application Real-Time Monitoring Service (ARMS) allows you to send alert notifications to contacts of specific instant messaging apps. This topic describes how to use a webhook to send notifications to Lark contacts.
Step 1: Obtain a webhook URL
- Open and log on to Lark.
- Click the + icon and then click New group to create a Lark group that is used to receive alert notifications.
- Click the Settings icon.
- In the Settings panel, click BOTs and then click Add Bot.
- On the Add Bot page, select Custom Bot.
- Configure the Bot name and Description parameters, and then click Add.
- Click Copy to the right of Webhook URL and then click Save.
Step 2: Create an alert contact
- Log on to the ARMS console. In the left-side navigation pane, choose .
- In the Edit Contact Group dialog box, click the Webhook tab and then click Add Webhook.
- In the Create Webhook panel, configure the following parameters. The following table describes the parameters.
Parameter Description Webhook Name Required. Enter a name for the webhook. Post or Get Required. Specify a request method and enter a URL. The URL cannot exceed 256 characters in length. In this example, Post is selected, and the webhook URL that is copied in Step 1: Obtain a webhook URL is pasted.
Header or Param Optional. Specify a request header. The request header cannot exceed 200 characters in length. Click Add to add a header or a parameter. The default request header is Content-Type: text/plain; charset=UTF-8. The total number of headers and parameters cannot exceed six. In this example, the following headers are used:- Arms-Content-Type : json
- Content-Type : application/json
Notification Template Optional. Specify the content that you want to send when the alert is triggered. This parameter appears only if you select Post. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length. For more information, see Configure a notification template and a webhook template. Specify the notification content in the following format:
{ "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 }}", "Notification content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
In this example, the following template is used:{ "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 }} \nNotification content: {{ for .alerts }} {{ .annotations.message }}\n {{ end }}" } }
Template to Clear Alerts Optional. Specify the content that you want to send when the alert is resolved. This parameter appears only if you select Post. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length. For more information, see Configure a notification template and a webhook template. Specify the notification content in the following format:
{ "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 }}", "Time when the alert is resolved":"{{ .endTime }}", "Notification content":"{{ for .alerts }} {{ .annotations.message }} {{ end }}" }
In this example, the following template is used:{ "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 }}Time when the alert is resolved: {{ .startTime }} \nNotification policy: {{ .dispatchRuleName }} \nNotification content: {{ for .alerts }} {{ .annotations.message }}\n {{ end }}" } }
- Optional:Click Test to verify whether the configurations are valid.
- Click OK.
Step 3: Set a notification policy
When you create or modify a notification policy, you can set the Notification Object parameter to Universal Webhook, and then select a webhook. For more information, see Create and manage a notification policy.