Legacy content templates support a set of variables that you can reference in the subject and body of alert notifications. This page lists all available variables and their reference syntax.
Reference syntax
Variable names must match exactly. A nonexistent or incorrectly referenced variable resolves to an empty string. If the referenced value is an object, it is converted to a JSON string.
When you configure an action policy, you must select a content template that defines the notification content and subject. In the Content and Subject fields, reference template variables by using the ${fieldName} format. When Log Service sends an alert notification, it replaces the template variables in the Content and Subject with actual values. For example, ${project} is replaced with the name of the Project to which the alert rule belongs.
Available variables
The following table lists the available variables and their reference methods.
|
Parameter |
Description |
Type |
Example value |
Reference example |
|
aliuid |
The ID of the Alibaba Cloud account that owns the Project. |
string |
117918664953**** |
An alert rule for user |
|
alert_instance_id |
The ID of the alert instance that was triggered. |
string |
ee16a8f435485f3f-5be6b81edc520-3d6**** |
The instance ID is |
|
project |
The Project that contains the alert rule. |
string |
my-project |
An alert rule in the |
|
alert_id |
The ID of the alert rule. The ID is unique within a Project. |
string |
0fdd88063a611aa114938f9371daeeb6-1671a52**** |
The alert rule ID is |
|
alert_type |
The alert type.
|
string |
sls_alert |
The alert type is |
|
alert_name |
The name of the alert rule. |
string |
Alert Rule new2 |
The alert rule |
|
next_eval_interval |
The interval, in seconds, before the next evaluation. |
int |
900 |
The next evaluation will occur in |
|
alert_time |
The time of the current evaluation. |
int |
1616744734 |
The current evaluation time is |
|
fire_time |
The time when the alert was first triggered. |
int |
1616059834 |
The alert was first triggered at |
|
status |
The alert status.
|
string |
firing |
The alert status is |
|
resolve_time |
The time when the alert was resolved.
|
int |
0 |
The alert was resolved at |
|
results |
An array of query parameters and intermediate results. For details, see Query data structure. |
array |
|
Start time for the first query: Note
The |
|
labels |
A map of the alert's labels. |
map |
{"env":"test"} |
The alert labels are |
|
annotations |
A map of the alert's annotations. |
map |
{ "title": "Alert Title","desc": "Alert Description" } |
The alert annotations are |
|
severity |
The alert severity.
|
int |
10 |
The alert severity is |
|
policy |
The alert policy or action policy. For details, see Policy structure. |
map |
|
The alert policy ID is |
|
region |
The region. |
string |
cn-hangzhou |
The alert was triggered in the |
|
drill_down_query |
The query statement for drill-down analysis. This value is an empty string for custom alerts. This variable is used in content templates for Log Audit Service, Cost Manager, and SLB. |
string |
|
The drill-down query is |
|
alert_url |
The URL of the alert details page. |
string |
https://sls.console.alibabacloud.com/lognext/project/test-xxxx/alert/alert-1617164106-940166 |
The alert URL is |
|
query_url |
The URL for the results page of the first query. |
string |
https://sls-stgnew.console.alibabacloud.com/lognext/project/test-xxx/logsearch/test-alert-access?encode=base64&endTime=1617175989&queryString=KiB8IHNlbGVjdCBjb3VudCgxKSBhcyBjbnQ%3D&queryTimeType=99&startTime=1617175089 |
The URL for the first query page is |
|
alert_history_dashboard_url |
The URL of the alert history dashboard. |
string |
https://sls.console.alibabacloud.com/lognext/project/test-xx/dashboard/internal-alert-analysis |
The URL for the alert history dashboard is |
|
condition |
The evaluation expression that triggered the alert, with variables replaced by their actual values and enclosed in square brackets ( |
string |
|
The alert evaluation expression is |
|
raw_condition |
The original evaluation expression before variables are replaced with actual values. Format: |
string |
|
The original evaluation expression is |
|
dashboard |
The name of the dashboard associated with the alert. |
string |
mydashboard |
The associated dashboard name is |
|
dashboard_url |
The URL of the dashboard associated with the alert. |
string |
https://sls.console.alibabacloud.com/next/project/myproject/dashboard/mydashboard |
The URL for the associated dashboard is |
|
fire_results |
The data that triggered the alert after set operations. A maximum of 100 rows are returned. |
array |
|
The data that triggered the alert is |
|
fire_results_count |
The total number of rows that triggered the alert. This count may exceed 100, such as after a Cartesian product operation. |
int |
3 |
The total number of data rows that triggered the alert is |
|
fire_results_as_kv |
The data that triggered the alert after set operations, displayed in the |
array |
|
Details of the data that triggered the alert: |
Policy structure
The following table describes the fields in the policy variable.
|
Field |
Description |
Type |
Example |
|
alert_policy_id |
The ID of the alert policy. |
string |
sls.test-alert |
|
action_policy_id |
The ID of the action policy specified by the alert rule. This field applies only when the alert policy uses a dynamic action policy. |
string |
sls.test-action |
|
repeat_interval |
The repeat notification interval. This field applies only when the alert policy uses an action policy. |
string |
4h |
Query data structure
The following table describes the fields in each object of the results array.
|
Parameter |
Description |
Type |
Example |
|
role_arn |
The service role used for the query. |
string |
acs:ram::117918664953****:role/aliyunslsalertmonitorrole |
|
store_type |
The storage type.
|
string |
log |
|
region |
The region of the target data store. This field is empty when the storage type is |
string |
cn-hangzhou |
|
project |
The Project that contains the target data store. This field is empty when the storage type is |
string |
sls-test-alert |
|
store |
The name of the target data store. |
string |
test-LogStore |
|
query |
The query statement. |
string |
error | select count(1) as cnt |
|
start_time |
The start time of the query. This field is empty when the storage type is |
int |
2006-01-02 15:04:05 |
|
start_time_ts |
The start time of the query in UNIX timestamp format. This field is empty when the storage type is |
int |
1616741485 |
|
end_time |
The end time of the query. This field is empty when the storage type is |
int |
2006-01-02 15:04:05 |
|
end_time_ts |
The end time of the query in UNIX timestamp format. This field is empty when the storage type is |
int |
1616745085 |
|
dashboard_id |
The ID of the dashboard associated with the query. |
string |
mydashboard |
|
raw_results |
An array of raw query results. A maximum of 100 rows are returned. |
array |
|