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 webhook alert notifications to Feishu, WeChat, and DingTalk groups. This topic describes how to create a webhook alert. Feishu is used in this example.

Step 1: Obtain a webhook URL

  1. Open and log on to Feishu.
  2. Click the + icon and then click New group to create a Feishu group that is used to receive alert notifications.
  3. Click the Settings icon.
  4. In the Settings panel, click BOTs and then click Add Bot.
    Add a bot to a Feishu group
  5. In the Add Bot dialog box, click Add in the Custom Bot section.
    Create a custom bot in Feishu
  6. Set the Bot name and Description parameters and click Add.
    Configure a custom bot in Feishu
  7. Click Copy next to Webhook URL and then click Finish.
    Copy a webhook URL in Feishu

Step 2: Create an alert contact

  1. Log on to the EDAS console.
  2. On the Applications page, select EDAS Kubernetes Cluster or Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list. Then click the name of the application for which you want to create an alert contact.
  3. In the left-side navigation pane, choose Alert Management > Contact.
  4. On the Contact tab, click New webhook in the upper-right corner.
  5. In the Create Webhook dialog box, set the parameters.

    The following table describes the parameters.

    Parameter Description
    Webhook name Required. The custom webhook name.
    Post and Get Required. The request method. The requested URL cannot exceed 100 characters in length.

    In this example, select Post and paste the webhook URL that is saved in the Step 1: Obtain a webhook URL section to the field.

    Header and Param Optional. The request header. The length cannot exceed 200 characters in length. Click Add to add a header or 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, set the following two headers:
    • Arms-Content-Type : json
    • Content-Type : application/json
    Notification template Optional. Specify the content to be sent when the alert is triggered. This parameter appears only when Post is selected. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length. 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 where Feishu is used, specify the notification content in the following format:
    {
      "msg_type": "text",
      "content": {
        "text": "Alert name: {{ .commonLabels.alertname }}\nAlert time: {{ .startTime }}\nNotification content: {{ for .alerts }} {{ .annotations.message }}  {{if .generatorURL }} Details link: {{.generatorURL}} {{ end }} \n {{ end }}"
      }
    }
    Restore Template Optional. Specify the content to be sent when the alert is resolved. This parameter appears only when Post is selected. You can use the $content placeholder to specify the notification content. The content cannot exceed 500 characters in length. 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 where Feishu is used, specify the notification content in the following format:
    {
      "msg_type": "text",
      "content": {
        "text": "Alert name: {{ .commonLabels.alertname }}\nTime when the alert is resolved: {{ .endTime }}\nNotification content: {{ for .alerts }} {{ .annotations.message }}  {{if .generatorURL }} Details link: {{.generatorURL}} {{ end }} \n {{ end }}"
      }
    }
  6. Optional:Click Test to verify whether the configurations are valid.
  7. Click Create.

Step 3: Set a notification policy

To use the custom webhook URL to receive alert notifications, you must set the Notification method parameter to WebHook when you set a notification.

Create or modify a dispatch policy. On the Notification policy page, set the Contact parameter to the created webhook contact and select WebHook for the Notification method parameter. For more information, see Configure a notification policy.
Note If the specified webhook receives no response within 5 seconds after a notification is sent, the sending fails.