All Products
Search
Document Center

Auto Scaling:Creates an event-triggered task

Last Updated:Oct 27, 2023

This topic provides an example of how to call an API operation to create an event-triggered task.

Description

In this example, the following parameters are used to create an event-triggered task:

  • ScalingGroupId: the ID of the scaling group for which you want to create the event-triggered task.

  • MetricName: the name of the metric that is monitored by the event-triggered task. The value of this parameter varies based on the type of the event-triggered task.

  • MetricType: the type of the metric.

  • Period: the period during which the metric data is collected. Unit: seconds.

  • Statistics: the method that is used to collect statistics on the metric data. Valid values: Average, Minimum, and Maximum.

  • Threshold: the threshold of the metric. If the threshold is reached the specified number of times, the event-triggered task is triggered to execute a scaling rule.

  • ComparisonOperator: the comparator between the statistics on the metric data and the threshold. The combination of a metric, a threshold, and a comparator is used to specify the condition under which the event-triggered task is triggered. For example, the >= comparator specifies that the statistical metric data is greater than and equal to the threshold.

For more information about the parameters, see CreateAlarm.

Sample requests

http(s)://ess.aliyuncs.com/?Action=CreateAlarm
&RegionId=cn-hangzhou
&Name=TestAlarmTask
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&MetricName=CpuUtilization
&MetricType=system
&Period=300
&Statistics=Average
&Threshold=80.0
&ComparisonOperator=>=
&<Common request parameters>

Sample responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateAlarmResponse>
    <AlarmTaskId>asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1****</AlarmTaskId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</CreateAlarmResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "AlarmTaskId" : "asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1****",
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}