If an event-triggered task for a scaling group no longer meets your requirements, you can call the ModifyAlarm operation to modify the properties of the task. This saves the time and resources that would be required to create a new task.
Usage notes
If you create an event-triggered task of the custom monitoring type (MetricType=custom), you must first report the custom metrics to CloudMonitor. For more information, see Event-triggered tasks for custom monitoring.
When you create an event-triggered task, you must specify the metric (MetricName) and its dimensions (
Dimension.N.DimensionKeyandDimension.N.DimensionValue). This defines the aggregation scope for the metric data within the scaling group. For example, you can specifyuser_idandscaling_groupto aggregate the metric data for all Elastic Compute Service (ECS) instances or ECI instances that belong to the specified user and scaling group.For an event-triggered task of the custom monitoring type (MetricType=custom), the metrics are based on your custom monitoring metrics.
For more information about the metrics supported for an event-triggered task of the system monitoring type (MetricType=system), see Event-triggered tasks for system monitoring.
The user_id and scaling_group dimensions are automatically populated. You must manually specify the device and state dimensions. For more information, see the descriptions of the Dimension.N.DimensionKey and Dimension.N.DimensionValue parameters.
Test the API
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | ModifyAlarm | The action to perform. Set the value to ModifyAlarm. |
RegionId | String | Yes | cn-qingdao | The ID of the region where the event-triggered task is located. |
AlarmTaskId | String | Yes | asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1**** | The ID of the event-triggered task. |
Name | String | No | alarmtask**** | The name of the event-triggered task. |
Description | String | No | Test alarm task. | The description of the event-triggered task. |
MetricName | String | No | MemoryUtilization | The name of the metric. The valid values of this parameter vary based on the value of MetricType.
For more information, see Event-triggered tasks for system monitoring. |
MetricType | String | No | system | The type of the metric. Valid values:
|
Period | Integer | No | 300 | The statistical period for the metric. Unit: seconds. Valid values:
|
Statistics | String | No | Average | The aggregation method for the metric. Valid values:
|
Threshold | Float | No | 80 | The threshold for the metric. A scaling rule is executed if the threshold is met for a specified number of consecutive statistical periods. |
ComparisonOperator | String | No | >= | The comparison operator between the metric value and the threshold. This operator defines when the condition is met. Valid values:
|
EvaluationCount | Integer | No | 3 | The number of consecutive times the threshold must be met before the scaling rule is executed. For example, if you set this parameter to 3, the scaling rule is executed only if the average CPU utilization is greater than or equal to 80% for three consecutive statistical periods. |
GroupId | Integer | No | 4055401 | The ID of the Cloud Monitor application group to which the custom metric belongs. This parameter is required only when MetricType is set to custom. |
Effective | String | No | TZ=+00 * * 1-2 * * ? | The effective period of the event-triggered task. This parameter follows the cron expression format. The default format is
Note By default, the value of this parameter is in the UTC+8 time zone. You can specify a time zone before the cron expression. For example, to specify UTC+0, use Examples:
|
AlarmAction.N | String | No | ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp163l21e07uhn**** | The unique identifier of the scaling rule to be associated with the event-triggered task. |
Dimension.N.DimensionKey | String | No | device | The key of a dimension associated with the metric. The valid values vary based on the value of MetricType.
|
Dimension.N.DimensionValue | String | No | eth0 | The value of a dimension associated with the metric. The valid values vary based on the value of Dimension.N.DimensionKey.
|
Expression.N.MetricName | String | No | CpuUtilization | The name of a metric in the multi-metric rule. The valid values vary based on the value of MetricType.
For more information, see Event-triggered tasks for system monitoring. |
Expression.N.ComparisonOperator | String | No | >= | The comparison operator for the metric in the multi-metric rule. This operator defines when the condition is met. Valid values:
Default value: |
Expression.N.Period | Integer | No | 300 | The statistical period for the metric in the multi-metric rule. Unit: seconds. Valid values:
Default value: 300. |
Expression.N.Statistics | String | No | Average | The aggregation method for the metric in the multi-metric rule. Valid values:
|
Expression.N.Threshold | Float | No | 40.0 | The threshold for the metric in the multi-metric rule. A scaling rule is executed if the threshold is met for a specified number of consecutive statistical periods. |
ExpressionsLogicOperator | String | No | && | The relationship between the conditions of the multi-metric rule. Valid values:
Default value: |
Response parameters
Parameter | Type | Example | Description |
AlarmTaskId | String | asg-bp1hvbnmkl10vll5**** | The ID of the event-triggered task. |
RequestId | String | BACACF83-7070-4953-A8FD-D81F89F1**** | The ID of the request. |
Examples
Sample request
http(s)://ess.aliyuncs.com/?Action=ModifyAlarm
&RegionId=cn-qingdao
&AlarmTaskId=asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1****
&Name=alarmtask****
&Description=Test alarm task.
&MetricName=MemoryUtilization
&MetricType=system
&Period=300
&Statistics=Average
&Threshold=80.0
&ComparisonOperator=>=
&EvaluationCount=3
&GroupId=4055401
&Effective=TZ=+00 * * 1-2 * * ?
&AlarmAction=["ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp163l21e07uhn****"]
&Dimension=[{"DimensionKey":"device","DimensionValue":"eth0"}]
&Expression=[{"MetricName":"CpuUtilization","ComparisonOperator":">=","Period":300,"Statistics":"Average","Threshold":40.0}]
&ExpressionsLogicOperator=&&
&Common request parametersSample responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<ModifyAlarmResponse>
<AlarmTaskId>asg-bp1hvbnmkl10vll5****</AlarmTaskId>
<RequestId>BACACF83-7070-4953-A8FD-D81F89F1****</RequestId>
</ModifyAlarmResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"AlarmTaskId" : "asg-bp1hvbnmkl10vll5****",
"RequestId" : "BACACF83-7070-4953-A8FD-D81F89F1****"
}Error codes
For a list of error codes, visit the Error Center.