Log Service sends alert notifications based on the content that is specified in alert templates.

Procedure

  1. Log on to the Log Service console.
  2. Go to the Alert Template page.
    1. In the Projects section, click the name of the project that you want to view.
    2. In the left navigation sidebar, click the 告警 icon.
    3. Click Open Alert Center. On the page that appears, choose Alert Management > Alert Template.
  3. Create an alert template.
    1. Click Create.
    2. Enter an ID and name for the alert template.
    3. Configure the content for each notification method.
      You can configure the content on each of the following tabs within an alert template: SMS, Voice, Email, DingTalk, WebHook-Custom, Notifications, Enterprise WeChat, Lark, and Slack.
      Tab Description
      SMS You can configure the following parameters:
      • Language: the natural language of an alert notification. Valid values: Chinese and English.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Voice You can configure the following parameters:
      • Language: the natural language of an alert notification. Valid values: Chinese and English.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Email You can configure the following parameters:
      • Language: the natural language of an alert notification. Valid values: Chinese and English.
      • Subject: the subject of an alert notification. You can directly enter the subject or use template variables to define the subject.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      DingTalk You can configure the following parameters:
      • Title: the title of an alert notification. You can directly enter the title or use template variables to define the title.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Webhook-Custom You can configure the following parameters:
      • Sending Mode: the mode in which alert notifications are sent. Valid values: Single and Batch.
        • If you select Batch and specify the Maximum number of items sent in a group parameter, only the first N alerts of an alert set are sent. N is the specified number.
        • If you select Batch and specify the content that can be parsed as JSON, alerts are sent in the JSON format. If the content cannot be parsed as JSON in this situation, alerts are sent in the ARRAY format. The arrays contain strings.
        For example, if you specify the content as { "project": "${project}", "alert_name": "${alert_name}"}, the following notifications are sent when two alerts are generated:
        • Single: Two alert notifications are sent. Content: { "project": "project-1", "alert_name": "alert-1"} and { "project": "project-2", "alert_name": "alert-2"}.
        • Batch: One alert notification is sent. Content: [{ "project": "project-1", "alert_name": "alert-1"}, { "project": "project-2", "alert_name": "alert-2"}].
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Note When Log Service sends alert notifications, the request header Content-Type: application/json;charset=utf-8 Header is used by default. If a webhook receiver requires a request header in a different format, you can customize the request header when you configure the notification methods. For more information, see Webhook.
      Notifications You can configure the following parameters:
      • Language: the natural language of an alert notification. Valid values: Chinese and English.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Enterprise WeChat You can configure the following parameters:
      • Title: the title of an alert notification. You can directly enter the title or use template variables to define the title.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Lark You can configure the following parameters:
      • Title: the title of an alert notification. You can directly enter the title or use template variables to define the title.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.
      Slack You can configure the following parameters:
      • Title: the title of an alert notification. You can directly enter the title or use template variables to define the title.
      • Content: the content of an alert notification. You can directly enter the content or use template variables to define the content. For more information, see Template variables.