This topic describes the variables that are available for use in the original alert templates of Simple Log Service. This topic also describes the methods that you can use to reference the variables.
Reference methods
You must reference variables by using the full names of the variables. If a referenced variable cannot be found or is invalid, Simple Log Service replaces the variable with an empty string. If the value of a referenced variable is of the object type, the value is converted into a JSON string.
When you configure an action policy, you must select an alert template. The alert template specifies the content and subject of alert notifications. When you configure the Content and Subject parameters, you can use the ${fieldName}
syntax to reference the variables in the alert template. Before Simple Log Service sends an alert notification, Simple Log Service replaces the variables that are referenced in the Content and Subject fields with the actual values. For example, Simple Log Service replaces ${project}
with the name of the project to which the configured alert rule belongs.
Available variables and reference examples
The following table describes the available variables and provides examples on how to reference the variables.
Variable | Description | Type | Value example | Reference example |
aliuid | The ID of the Alibaba Cloud account to which the project belongs. | string | 117918664953**** | The project in which the alert is triggered belongs to the |
alert_instance_id | The ID of the instance for which the alert is triggered. | string | ee16a8f435485f3f-5be6b81edc520-3d6**** | The ID of the instance for which the alert is triggered is |
project | The project to which the alert rule belongs. | string | my-project | The alert is triggered in the |
alert_id | The ID of the alert rule. Each alert rule must have a unique ID in the project to which the alert rule belongs. | string | 0fdd88063a611aa114938f9371daeeb6-1671a52**** | The ID of the alert rule is |
alert_type | The type of the alert that is triggered.
| string | sls_alert | The type of the alert is |
alert_name | The name of the alert rule. | string | new2 | The name of the alert rule is |
next_eval_interval | The length of time before the next evaluation activity starts. | int | 900 | The next evaluation activity starts in |
alert_time | The time at which the current evaluation activity starts. | int | 1616744734 | The current evaluation activity starts at |
fire_time | The time at which the alert is triggered for the first time. | int | 1616059834 | The alert is triggered at |
status | The status of the alert.
| string | firing | The status of the alert is |
resolve_time | The time at which the alert is cleared.
| int | 0 | The alert is cleared at |
results | The parameters and intermediate results of the query. The value of this variable is an array. For more information about the value of this variable, see the "Description of the results variable" section of this topic. | array |
| The query starts at Note In this example, the value 0 is the serial number of the chart. |
labels | The labels of the alert. | map | {"env":"test"} | The labels of the alert are |
annotations | The annotations of the alert. | map | { "title": "Alert title","desc": "Alert description" } | The annotations of the alert are |
severity | The severity level of the alert.
| int | 10 | The severity level of the alert is |
policy | The alert policy or action policy that you configure. For more information about the value of this variable, see the "Description of the policy variable" section of this topic. | map |
| The ID of the alert policy is |
region | The ID of the region in which the alert is triggered. | string | cn-hangzhou | The alert is triggered in the |
drill_down_query | The query statement that is used for drill-down analysis. The value of this variable is empty for custom alert templates. This variable is available for use in the alert templates of Log Audit Service, Cost Manager, and SLB Log Center. | string |
| None. |
alert_url | The URL of the alert. | string | https://sls.console.aliyun.com/lognext/project/test-xxxx/alert/alert-1617164106-940166 | The URL of the alert is |
query_url | The URL of the first page that is requested in the query. | string | https://sls-stg.console.aliyun.com/lognext/project/test-xxx/logsearch/test-alert-access?encode=base64&endTime=1617175989&queryString=KiB8IHNlbGVjdCBjb3VudCgxKSBhcyBjbnQ%3D&queryTimeType=99&startTime=1617175089 | The URL of the first page that is requested in the query is |
alert_history_dashboard_url | The URL of the Alert History Statistics dashboard. | string | https://sls.console.aliyun.com/lognext/project/test-xx/dashboard/internal-alert-analysis | The URL of the Alert History Statistics dashboard is |
condition | The trigger condition of the alert rule. Simple Log Service replaces the variables in the trigger condition with the values that trigger the alert. Each value is enclosed in a pair of brackets ([]). The value of this variable is in the | string | Count:[5] > 3;Condition:[example.com]=='example.com' | The trigger condition of the alert rule is |
raw_condition | The original trigger condition of the alert rule. The variables in the trigger condition are retained. The value of this variable is in the | string |
| The original trigger condition of the alert rule is |
dashboard | The name of the dashboard that is associated with the alert rule. | string | mydashboard | The name of the dashboard that is associated with the alert rule is |
dashboard_url | The URL of the dashboard that is associated with the alert rule. | string | https://sls.console.aliyun.com/next/project/myproject/dashboard/mydashboard | The URL of the dashboard that is associated with the alert rule is |
fire_results | The data records for which the alert is triggered. Up to 100 data records can be returned in response to an operation on data sets. | array |
| The alert is triggered for the following data records: |
fire_results_count | The total number of data records for which the alert is triggered. The value of this variable may be greater than 100. For example, if you perform a CROSS JOIN operation on data sets, Simple Log Service may trigger an alert for more than 100 data records. | int | 3 | The alert is triggered for a total of |
fire_results_as_kv | The details about the data records for which the alert is triggered. Up to 100 data records can be returned in response to an operation on data sets. The value of this variable is in the | array | [host:example.com,pv:836,status:200][host:example.com,pv:780,status:200] | The alert is triggered for the following data records: |
Description of the policy variable
The following table describes the variables that can be referenced in the policy variable.
Variable | Description | Type | Example |
alert_policy_id | The ID of the alert policy that you configure in the alert rule. | string | sls.test-alert |
action_policy_id | The ID of the action policy that you configure in the alert rule. This variable is available only when you associate an alert policy with a dynamic action policy. | string | sls.test-action |
repeat_interval | The time interval at which Simple Log Service sends repeated alerts. This variable is available only when you associate an alert policy with an action policy. | string | 4h |
Description of the results variable
The following table describes the variables that can be referenced in the results variable.
Variable | Description | Type | Example |
role_arn | The Alibaba Cloud Resource Name (ARN) of the resource that you want to use. | string | acs:ram::1117918664953****:role/aliyunslsalertmonitorrole |
store_type | The type of data that you want to use. Valid values:
| string | log |
region | The region where the destination Logstore or the destination Metricstore resides. If the value of the store_type variable is meta, the region variable is empty. | string | cn-hangzhou |
project | The project to which the destination Logstore or the destination Metricstore belongs. If the value of the store_type variable is meta, the project variable is empty. | string | sls-test-alert |
store | The name of the destination Logstore or destination Metricstore. | string | test-logstore |
query | The query statement that you want to execute. | string | error | select count(1) as cnt |
start_time | The beginning of the time range that you want to query. If the value of the store_type variable is meta, the start_time variable is empty. | int | 2006-01-02 15:04:05 |
start_time_ts | The beginning of the time range that you want to query. The value is a UNIX timestamp. If the value of the store_type variable is meta, the start_time_ts variable is empty. | int | 1616741485 |
end_time | The end of the time range that you want to query. If the value of the store_type variable is meta, the end_time_ts variable is empty. | int | 2006-01-02 15:04:05 |
end_time_ts | The end of the time range that you want to query. The value is a UNIX timestamp. If the value of the store_type variable is meta, the end_time_ts variable is empty. | int | 1616745085 |
dashboard_id | The ID of the dashboard that is associated with the query. | string | mydashboard |
raw_results | The result that is returned in response to the query. The value of this variable is an array. Up to 100 data records are returned. | array |
|