This topic describes template variables that are supported in alert notifications and the methods used to reference the variables.

Reference methods

When you configure a notification method for an alert rule, you can use template variables. When you specify the Content and Subject parameters, you can use the ${fieldName} syntax to reference a template variable. When Log Service sends an alert notification, Log Service replaces the template variables that are referenced in the Content and Subject parameters with the actual values. For example, Log Service replaces ${Project} with the name of the project to which the alert rule belongs.
Notice You must reference valid variables. If a referenced variable does not exist or is invalid, Log Service processes the variable as an empty string. If the value of a referenced variable is of the object type, the value is converted and displayed as a JSON string.

Available variables and reference examples

Variable Description Reference example Alert notification example
Aliuid The ID of the Alibaba Cloud account to which a project belongs. An alert is triggered for the Alibaba Cloud account ${Aliuid}. An alert is triggered for the Alibaba Cloud account 1234567890.
Project The project to which an alert rule belongs. An alert is triggered in the ${Project} project. An alert is triggered in the my-project project.
AlertID The ID of an alert. The ID of the alert is ${AlertID}. The ID of the alert is 0fdd88063a611aa114938f9371daeeb6-1671a52eb23.
AlertName The ID of an alert rule. The ID is unique in a project. An alert is triggered based on the ${AlertName} alert rule. An alert is triggered based on the alert-1542111415-153472 alert rule.
AlertDisplayName The display name of an alert rule. An alert is triggered based on the ${AlertDisplayName} alert rule. An alert is triggered based on an alert rule named website monitoring.
Condition The conditional expression that triggers an alert. In an alert notification, the variable is replaced by an actual value that is enclosed in a pair of brackets []. The conditional expression that triggers an alert is ${Condition}. The conditional expression that triggers an alert is [5] > 1.
RawCondition The original conditional expression that triggers an alert. The original conditional expression that triggers an alert is ${RawCondition}. The original conditional expression that triggers an alert is count > 1.
Dashboard The name of the dashboard that is associated with an alert rule. The alert rule is associated with the ${Dashboard} dashboard. The alert rule is associated with the mydashboard dashboard.
DashboardUrl The URL of the dashboard that is associated with an alert rule. The URL of the dashboard that is associated with the alert rule is ${DashboardUrl}. The URL of the dashboard that is associated with the alert rule is https://sls.console.aliyun.com/next/project/myproject/dashboard/mydashboard.
FireTime The time when an alert is triggered. The alert is triggered at ${FireTime}. The alert is triggered at 2021-01-02 15:04:05.
FullResultUrl The URL that is used to query the details of an alert. Click ${FullResultUrl} to view the alert details. Click https://sls.console.aliyun.com/next/project/my-project/logsearch/internal-alert-history?endTime=1544083998&queryString=AlertID%3A9155ea1ec10167985519fccede4d5fc7-1678293caad&queryTimeType=99&startTime=1544083968 to view the alert details.
Results The results and parameters in query statistics. The variable is of the array type. The following example shows the Results variable.
Note The Results variable contains the information of up to 100 alerts.
[
  {
    "EndTime": "2021-05-21 18:33:12",
    "EndTimeTs": "1621593192",
    "FireResult": {
      "source": "",
      "time": "1621592292",
      "cnt": "2",
      "status": "403"
    },
    "FireResultAsKv": "[cnt:2,status:403]",
    "LogStore": "nginx-access-log",
    "Query": "status >= 400 | select status, count(*) as cnt group by status",
    "QueryUrl": "",
    "RawResultCount": 2,
    "RawResults": [
      {
        "__source__": "",
        "__time__": "1621592292",
        "cnt": "2",
        "status": "403"
      },
      {
        "__source__": "",
        "__time__": "1621592292",
        "cnt": "1",
        "status": "401"
      }
    ],
    "RawResultsAsKv": "[cnt:2,status:403] \n\n [cnt:1,status:401]",
    "StartTime": "2021-05-21 18:18:12",
    "StartTimeTs": "1621592292",
    "Truncated": false
  }
]

For more information, see Alert log fields.

The start time of the first query statistics is ${Results[0].StartTime}. The end time is ${Results[0].EndTime}.
Note In this example, the value 0 is the serial number of a chart. For more information about how to obtain the serial number of a chart, see How can I view the serial number of a chart?
The start time of the first query statistics is 2021-05-21 18:18:18:12. The end time is 2021-05-21 18:33:12.