Creates event-triggered tasks. If your business encounters unexpected traffic surges or has no specific patterns, you can call the CreateAlarm operation to create an event-triggered task and associate a CloudMonitor metric with the task. This allows you to dynamically adjust the number of Elastic Compute Service (ECS) instances or elastic container instances in your scaling group and keep updated on the real-time metric data, which facilitates cloud resource management and maintenance.
Operation description
-
If you set MetricType to custom, you must report your custom metrics to CloudMonitor before you can create event-triggered tasks by using the custom metrics. For more information, see Event-triggered tasks of the custom monitoring type.
-
When you create an event-triggered task, you must specify MetricName, Dimensions.DimensionKey, and Dimensions.DimensionValue to determine the range of statistics that you want to aggregate for the metrics of the scaling group. For example, you can specify user_id and scaling_group for an event-triggered task to aggregate monitoring data of all ECS instances or elastic container instances in a scaling group within an Alibaba Cloud account.
- If you create an event-triggered task of the custom monitoring type, you can specify only custom metrics in the task.
- If you create an event-triggered task of the system monitoring type, you can specify the system metrics described in Event-triggered tasks of the system monitoring type in the task.
Dimensions.DimensionKey
and Dimensions.DimensionValue
in the "Request parameters" section of this topic.
Debugging
Authorization information
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The region ID of the scaling group. | cn-hangzhou |
Name | string | No | The name of the event-triggered task. | TestAlarmTask |
Description | string | No | The description of the event-triggered task. | Test alarm task. |
ScalingGroupId | string | Yes | The scaling group ID of the event-triggered task. | asg-bp18p2yfxow2dloq**** |
MetricName | string | No | The metric name. The valid values of this parameter vary based on the metric type.
For more information, see Event-triggered tasks of the system monitoring type. | CpuUtilization |
MetricType | string | No | The type of the metric. Valid values:
| system |
Period | integer | No | The statistical period of the metric data. Unit: seconds. Valid values:
Note
You can set this parameter to 15 seconds only for scaling groups of the ECS type.
Default value: 300. | 300 |
Statistics | string | No | The method that is used to aggregate statistics for the metric. Valid values:
Default value: Average. | Average |
Threshold | float | No | The threshold of the metric value. If the threshold is reached the specified number of times within the specified period, a scaling rule is executed. | 80.0 |
ComparisonOperator | string | No | The operator that is used to compare the metric value and the threshold. Valid values:
Default value: >=. | >= |
EvaluationCount | integer | No | The number of times that the threshold must be reached before a scaling rule can be executed. For example, if you set this parameter to 3, the average CPU utilization must reach or exceed 80% three times in a row before a scaling rule is triggered. Default value: 3. | 3 |
GroupId | integer | No | The ID of the application group to which the custom metric belongs. If you set the MetricType parameter to custom, you must specify this parameter. | 4055401 |
Effective | string | No | The effective period of the event-triggered task. By default, the event-triggered task is in effect all the time. This parameter follows the cron expression format. The default format is
Note
By default, this parameter value is specified in UTC+8. You can specify the time zone in the TZ=+yy format before a cron expression. y indicates the time zone. For example, TZ=+00 * * 1-2 * * ? specifies that the event-triggered task is in effect between 01:00 and 02:59 (UTC+0) every day.
Sample values:
| TZ=+00 * * 1-2 * * ? |
AlarmActions | array | No | The list of unique identifiers of the scaling rules that are associated with the event-triggered task. | |
string | No | The list of unique identifiers of the scaling rules that are associated with the event-triggered task. | ari:acs:ess:cn-hangzhou:1406926****:scalingrule/asr-bp163l21e07uhn**** | |
Dimensions | object [] | No | The metric dimensions. | |
DimensionKey | string | No | The dimension key of the metric. The valid values vary based on the metric type.
| device |
DimensionValue | string | No | The dimension value of the metric. The valid values of this parameter vary based on the value of Dimensions.DimensionKey.
| eth0 |
Expressions | object [] | No | The information about the multi-metric alert rules. | |
MetricName | string | No | The names of the metrics in the multi-metric alert rule. The valid values of this parameter vary based on the metric type.
For more information, see Event-triggered tasks of the system monitoring type. | CpuUtilization |
ComparisonOperator | string | No | The operator that you want to use to compare the metric value and the threshold in the multi-metric alert rule. Valid values:
Default value: >=. | >= |
Period | integer | No | The statistical period of the metric data in the multi-metric alert rule. Unit: seconds. Valid values:
Note
You can set this parameter to 15 seconds only for scaling groups of the ECS type.
Default value: 300. | 900 |
Statistics | string | No | The method that you want to use to aggregate the metric data in the multi-metric alert rule. Valid values:
Default value: Average. | Average |
Threshold | float | No | The threshold of the metric value in the multi-metric alert rule. If the threshold is reached the specified number of times within the statistical period, a scaling rule is executed. | 40.0 |
ExpressionsLogicOperator | string | No | The relationship between the trigger conditions in the multi-metric alert rule. Valid values:
Default value: | && |
Response parameters
Examples
Sample success responses
JSON
format
{
"AlarmTaskId": "asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|