Updated on 2024-04-15 GMT+08:00

Creating a Message Template

You can create message templates to customize notifications. When a preset notification rule is triggered, notifications can be sent to specified personnel by emails or SMS. If no message template is created, the default message template will be used.

Functions

  • Message templates for emails and SMS are supported.
  • Message templates can be customized. For details, see 3.c.

Precautions

  • You can create up to 100 message templates. If the number of templates exceeds the upper limit, delete unnecessary templates and create new ones.
  • By default, one message template is preset and cannot be deleted or edited. If there is no custom message template, notifications are sent based on a preset message template by default.

Creating a Message Template

  1. On the menu bar, choose Monitoring Center.
  2. In the navigation pane, choose Alarm Management > Alarm Action Rules.
  3. On the Message Templates tab page, click Create.

    1. Enter a template name and description.
      Table 1 Parameter description

      Parameter

      Description

      Template Name

      Name of a message template. Enter up to 100 characters and do not start or end with an underscore (_) or hyphen (-). Only digits, letters, underscores, and hyphens are allowed.

      Description

      Description of the template. Enter up to 1024 characters.

    2. Select a language (for example, English).
    3. Customize the template content (default fields are automatically filled in when a message template is created). There are templates for emails and SMS. For details, see Table 2.
      • In addition to the message fields in the default template, the message template also supports custom fields. You need to specify the fields when reporting event alarms. For details, see the alarm reporting structs in the following message template.
      • Custom fields support the JSONPath format. Example: $event.metadata.case1 or $event.metadata.case[0].
      • In the upper right corner of the Body area, click Add Variables to add required variables.
      • If you select Emails, you can click Preview to view the final effect. On the Preview page, change the message topic if necessary.
      Table 2 Variables in the default message template

      Variable

      Description

      Definition

      Account

      Account used to log in to the management console.

      ${domain_name}

      Notification Type

      Type selected when an alarm rule is created, which can be Alarm or Event.

      ${event_type}

      Severity

      Alarm or event severity, which can be Critical, Major, Minor, or Warning.

      ${event_severity}

      Name

      Name of the alarm rule that is triggered.

      ${event_name}

      Occurred

      Time when the alarm or event is triggered.

      ${starts_at}

      Source

      Name of the service that triggers the alarm or event.

      ${resource_provider}

      Resource Type

      Type of the resource selected when you customize an alarm rule or define alarm reporting.

      ${resource_type}

      Resource Identifier

      Resource that triggers the alarm or event.

      ${resources}

      Possible Cause

      Cause of the alarm. For non-custom reporting, "NA" is displayed.

      ${alarm_probableCause_zh}

      Additional Info

      Additional alarm description, such as the metric name and alarm rule status change.

      ${message}

      Suggestion

      Suggestion on how to handle the alarm. For non-custom reporting, "NA" is displayed.

      ${alarm_fix_suggestion_zh}

      Alarm reporting structs corresponding to the message template
      {
      	"events": [{
      		"starts_at": 1579420868000,       //${starts_at}
                      "ends_at": 1579420868000,
      		"timeout": 60000,
      		"resource_group_id": "5680587ab6*******755c543c1f",
      		"metadata": {
      			"event_name": "test",         //${metadata.event_name}
      			"event_severity": "Major",    //${metadata.event_severity}
      			"event_type": "alarm",        //${metadata.event_type}
      			"resource_provider": "ecs",   //${metadata.resource_provider}
      			"resource_type": "vm",        //${metadata.resource_type}
      			"resource_id": "ecs123",
      			"key1": "Custom field"          //$event.metadata.key1
      		},
      		"annotations": {
      			"alarm_probableCause_zh_cn": "possible cause",     //${annotations.alarm_probableCause_zh}
      			"alarm_fix_suggestion_zh_cn": "fix suggestion",    //${annotations.alarm_fix_suggestion_zh}
      			"key2": "Custom field"    //$event.annotations.key2
      		}
      	}]
      }
      
    4. Click Confirm. The message template is created.

More Operations

After creating a message template, you can perform the operations listed in Table 3.

Table 3 Related operations

Operation

Description

Editing a message template

Click Edit in the Operation column.

Copying a message template

Click Copy in the Operation column.

Deleting a message template

  • To delete a single message template, click Delete in the Operation column in the row that contains the template, and then click Yes on the displayed page.
  • To delete one or more message templates, select them, click Delete above the template list, and then click Yes on the displayed page.
    NOTE:

    Before deleting a message template, delete the alarm action rules bound to it.

Searching for a message template

Enter a template name in the search box in the upper right corner and click .