All Products
Search
Document Center

Auto Scaling:ModifyAlarm

更新时间:Dec 12, 2025

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.DimensionKey and Dimension.N.DimensionValue). This defines the aggregation scope for the metric data within the scaling group. For example, you can specify user_id and scaling_group to 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.

Note

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

You can call this operation directly in OpenAPI Explorer. This eliminates the need to calculate signatures. After a successful call, OpenAPI Explorer automatically generates sample code for different SDKs.

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.

  • If MetricType is set to custom, the value of this parameter is the name of a custom metric.

  • If MetricType is set to system, the value can be one of the following system metrics:

    • CpuUtilization: CPU utilization of an ECS instance. Unit: %.

    • IntranetTx: Outbound traffic over the internal network of an ECS instance. Unit: Kbit/min.

    • IntranetRx: Inbound traffic over the internal network of an ECS instance. Unit: Kbit/min.

    • VpcInternetTx: Outbound traffic over the internet from a VPC-connected ECS instance. Unit: Kbit/min.

    • VpcInternetRx: Inbound traffic over the internet to a VPC-connected ECS instance. Unit: Kbit/min.

    • SystemDiskReadBps: The number of bytes read from the system disk of an ECS instance per second. Unit: bytes/s.

    • SystemDiskWriteBps: The number of bytes written to the system disk of an ECS instance per second. Unit: bytes/s.

    • SystemDiskReadOps: The number of read IOPS on the system disk of an ECS instance. Unit: counts/s.

    • SystemDiskWriteOps: The number of write IOPS on the system disk of an ECS instance. Unit: counts/s.

    • CpuUtilizationAgent: CPU utilization, collected by the CloudMonitor agent. Unit: %.

    • GpuUtilizationAgent: GPU utilization, collected by the CloudMonitor agent. Unit: %.

    • GpuMemoryFreeUtilizationAgent: Idle GPU memory usage, collected by the CloudMonitor agent. Unit: %.

    • GpuMemoryUtilizationAgent: GPU memory usage, collected by the CloudMonitor agent. Unit: %.

    • MemoryUtilization: Memory usage, collected by the CloudMonitor agent. Unit: %.

    • LoadAverage: Average system load, collected by the CloudMonitor agent.

    • TcpConnection: Total number of TCP connections, collected by the CloudMonitor agent. Unit: count.

    • TcpConnection: Number of established TCP connections, collected by the CloudMonitor agent. Unit: count.

    • PackagesNetOut: Number of packets sent by the NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetIn: Number of packets received by the NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetOut: Number of packets sent by the public-facing NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetIn: Number of packets received by the public-facing NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • EciPodCpuUtilization: CPU utilization of an ECI pod. Unit: %.

    • EciPodMemoryUtilization: Memory usage of an ECI pod. Unit: %.

    • LoadBalancerRealServerAverageQps: QPS of a single server in an ALB server group. Unit: counts/s.

For more information, see Event-triggered tasks for system monitoring.

MetricType

String

No

system

The type of the metric. Valid values:

  • system: system metrics of Cloud Monitor.

  • custom: custom metrics reported to Cloud Monitor.

Period

Integer

No

300

The statistical period for the metric. Unit: seconds. Valid values:

  • 15

  • 60

  • 120

  • 300

  • 900

    Note

    You can set the statistical period to 15 seconds only for scaling groups that contain ECS instances.

Statistics

String

No

Average

The aggregation method for the metric. Valid values:

  • Average

  • Minimum

  • Maximum

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:

  • >=: greater than or equal to

  • <=: less than or equal to

  • >: greater than

  • <: less than

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 X X X X X ?. The fields are, in order, Seconds, Minutes, Hours, Day of month, and Month.

  • X can be a specific value or a special character with a logical meaning. For more information about the valid values of X, see Cron expressions.

  • ? indicates that no value is specified.

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 TZ=+00 * * 1-2 * * ?. This means the task is effective from 01:00 to 02:59 (UTC+0) every day.

Examples:

  • * * * * * ? : The task is always effective.

  • * * 17-18 * * ? : The task is effective from 17:00 to 18:59 (UTC+8) every day.

  • TZ=+00 * * 1-2 * * ?: The task is effective from 01:00 to 02:59 (UTC+0) every day.

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.

  • If MetricType is set to custom, you can specify this parameter as needed.

  • If MetricType is set to system, you can set this parameter to one of the following values:

    • user_id: The ID of your Alibaba Cloud account.

    • scaling_group: The scaling group that is monitored.

    • device: The type of the NIC.

    • state: The state of the TCP connection.

    • rulePool: The server group specified for the QPS metric of an ALB instance.

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.

  • If Dimension.N.DimensionKey is a custom key (MetricType is custom), you can specify this parameter as needed.

  • If Dimension.N.DimensionKey is a system-defined key (MetricType is system), this parameter can have the following values:

    • user_id: The system automatically populates this value.

    • scaling_group: The system automatically populates this value.

    • device:

      • eth0: For instances in the classic network, eth0 represents the internal NIC. For instances in a VPC, only the eth0 NIC exists.

      • eth1: For instances in the classic network, eth1 represents the public NIC.

    • state:

      • TCP_TOTAL: The total number of TCP connections.

      • ESTABLISHED: The number of established TCP connections.

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.

  • If MetricType is set to custom, the value of this parameter is the name of a custom metric.

  • If MetricType is set to system, the value can be one of the following system metrics:

    • CpuUtilization: CPU utilization of an ECS instance. Unit: %.

    • IntranetTx: Outbound traffic over the internal network of an ECS instance. Unit: Kbit/min.

    • IntranetRx: Inbound traffic over the internal network of an ECS instance. Unit: Kbit/min.

    • VpcInternetTx: Outbound traffic over the internet from a VPC-connected ECS instance. Unit: Kbit/min.

    • VpcInternetRx: Inbound traffic over the internet to a VPC-connected ECS instance. Unit: Kbit/min.

    • SystemDiskReadBps: The number of bytes read from the system disk of an ECS instance per second. Unit: bytes/s.

    • SystemDiskWriteBps: The number of bytes written to the system disk of an ECS instance per second. Unit: bytes/s.

    • SystemDiskReadOps: The number of read IOPS on the system disk of an ECS instance. Unit: counts/s.

    • SystemDiskWriteOps: The number of write IOPS on the system disk of an ECS instance. Unit: counts/s.

    • CpuUtilizationAgent: CPU utilization, collected by the CloudMonitor agent. Unit: %.

    • GpuUtilizationAgent: GPU utilization, collected by the CloudMonitor agent. Unit: %.

    • GpuMemoryFreeUtilizationAgent: Idle GPU memory usage, collected by the CloudMonitor agent. Unit: %.

    • GpuMemoryUtilizationAgent: GPU memory usage, collected by the CloudMonitor agent. Unit: %.

    • MemoryUtilization: Memory usage, collected by the CloudMonitor agent. Unit: %.

    • LoadAverage: Average system load, collected by the CloudMonitor agent.

    • TcpConnection: Total number of TCP connections, collected by the CloudMonitor agent. Unit: count.

    • TcpConnection: Number of established TCP connections, collected by the CloudMonitor agent. Unit: count.

    • PackagesNetOut: Number of packets sent by the NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetIn: Number of packets received by the NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetOut: Number of packets sent by the public-facing NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • PackagesNetIn: Number of packets received by the public-facing NIC, collected by the CloudMonitor agent. Unit: packets/s.

    • EciPodCpuUtilization: CPU utilization of an ECI pod. Unit: %.

    • EciPodMemoryUtilization: Memory usage of an ECI pod. Unit: %.

    • LoadBalancerRealServerAverageQps: QPS of a single server in an ALB server group. Unit: counts/s.

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:

  • >=: greater than or equal to

  • <=: less than or equal to

  • >: greater than

  • <: less than

Default value: >=.

Expression.N.Period

Integer

No

300

The statistical period for the metric in the multi-metric rule. Unit: seconds. Valid values:

  • 15

  • 60

  • 120

  • 300

  • 900

    Note

    You can set the statistical period to 15 seconds only for scaling groups that contain ECS instances.

Default value: 300.

Expression.N.Statistics

String

No

Average

The aggregation method for the metric in the multi-metric rule. Valid values:

  • Average

  • Minimum

  • Maximum

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:

  • &&: An alert is triggered only if all conditions are met. This means all expressions in the multi-metric rule must evaluate to true.

  • ||: An alert is triggered if any one of the conditions is met.

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 parameters

Sample 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.