All Products
Search
Document Center

Auto Scaling:CreateAlarm

Last Updated:Aug 28, 2026

Creates an event-triggered task associated with a CloudMonitor metric to dynamically adjust the number of Elastic Compute Service (ECS) instances or elastic container instances in a scaling group based on real-time monitoring data.

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, specify MetricName, Dimensions.DimensionKey, and Dimensions.DimensionValue to define the statistics aggregation range. For example, specify user_id and scaling_group 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.

Note

user_id and scaling_group are automatically populated. You need to only specify device and state. For more information, see Dimensions.DimensionKey and Dimensions.DimensionValue in the "Request parameters" section of this topic.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:CreateAlarm

create

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}

None None

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. Valid values vary based on the metric type.

  • If you set MetricType to custom, the valid values are the metrics that you have.

  • If you set MetricType to system, this parameter has the following valid values:

    • CpuUtilization: the CPU utilization. Unit: %.

    • ConcurrentConnections: the number of concurrent connections.

    • IntranetTx: the outbound traffic over an internal network. Unit: KB/min.

    • IntranetRx: the inbound traffic over an internal network. Unit: KB/min.

    • VpcInternetTx: the outbound traffic over a virtual private cloud (VPC). Unit: KB/min.

    • VpcInternetRx: the inbound traffic over a VPC. Unit: KB/min.

    • SystemDiskReadBps: the number of bytes read from the system disk per second.

    • SystemDiskWriteBps: the number of bytes written to the system disk per second.

    • SystemDiskReadOps: the read IOPS of the system disk. Unit: counts/s.

    • SystemDiskWriteOps: the write IOPS of the system disk. Unit: counts/s.

    • CpuUtilizationAgent: the CPU utilization. Unit: %.

    • GpuUtilizationAgent: the GPU utilization. Unit: %.

    • GpuMemoryFreeUtilizationAgent: the idle GPU memory usage. Unit: %.

    • GpuMemoryUtilizationAgent: the GPU memory usage. Unit: %.

    • MemoryUtilization: the memory usage. Unit: %.

    • LoadAverage: the average system load.

    • TcpConnection: the total number of TCP connections.

    • TcpConnection: the number of established TCP connections.

    • PackagesNetOut: the number of packets sent by the internal network interface controller (NIC). Unit: counts/s.

    • PackagesNetIn: the number of packets received by the internal NIC. Unit: counts/s.

    • PackagesNetOut: the number of packets sent by the public NIC. Unit: counts/s.

    • PackagesNetIn: the number of packets received by the public NIC. Unit: counts/s.

    • EciPodCpuUtilization: the CPU utilization. Unit: %.

    • EciPodMemoryUtilization: the memory usage. Unit: %.

    • LoadBalancerRealServerAverageQps: the queries per second (QPS) of an instance.

For more information, see Event-triggered tasks of the system monitoring type.

CpuUtilization

MetricType

string

No

The metric type. Valid values:

  • system: system metrics of CloudMonitor.

  • custom: custom metrics that are reported to CloudMonitor.

system

Period

integer

No

The statistical period of the metric data. Unit: seconds. Valid values:

  • 15

  • 60

  • 120

  • 300

  • 900

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 statistical method for the metric data. Valid values:

  • Average: the average value.

  • Minimum: the minimum value.

  • Maximum: the maximum value.

Default value: Average.

Average

Threshold

number

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 for comparing the metric value with the threshold. Valid values:

  • If the metric value is greater than or equal to the threshold, set the value to >=.

  • If the metric value is less than or equal to the metric threshold, set the value to <=.

  • If the metric value is greater than the metric threshold, set the value to >.

  • If the metric value is less than the metric threshold, set the value to <.

Default value: >=.

>=

EvaluationCount

integer

No

The number of consecutive times the threshold must be reached before a scaling rule is executed. For example, if you set this parameter to 3, the average CPU utilization must reach or exceed 80% three consecutive times before the scaling rule is executed.

Default value: 3.

3

GroupId

integer

No

The application group ID of the custom metric. Required when MetricType is set to custom.

4055401

Effective

string

No

The effective period of the event-triggered task. Default: in effect at all times.

This parameter follows the cron expression format. The default format is X X X X X ?. In the format:

  • X: a placeholder for a field, which represents seconds, minutes, hours, days, and months in sequence. X can be a definite value or a special character that has logical meaning. For information about the valid values of X, see Cron expression.

  • ?: No value is specified.

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:

  • * * * * * ? : The event-triggered task is in effect all the time.

  • * * 17-18 * * ? : The event-triggered task is in effect between 17:00 and 18:59 (UTC+8) every day.

  • TZ=+00 * * 1-2 * * ?: The event-triggered task is in effect between 01:00 and 02:59 (UTC+0) every day.

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

array<object>

No

The metric dimensions.

object

No

The metric dimensions.

DimensionKey

string

No

The dimension key of the metric. Valid values vary based on the metric type.

  • If you set MetricType to custom, you can specify this parameter based on your business requirements.

  • If you set MetricType to system, this parameter has the following valid values:

    • user_id: the ID of your Alibaba Cloud account.

    • scaling_group: the scaling group that you want to monitor by using the event-triggered task.

    • device: the NIC type.

    • state: the status of the TCP connection.

device

DimensionValue

string

No

The dimension value of the metric. The valid values of this parameter vary based on the value of Dimensions.DimensionKey.

  • If you set MetricType to custom, you can specify this parameter based on your business requirements.

  • If you set MetricType to system, this parameter has the following valid values:

    • user_id: The system specifies the value.

    • scaling_group: The system specifies the value.

    • device: You can set this parameter to eth0 or eth1.

      • For instances of the classic network type, eth0 specifies the internal NIC. Only one eth0 NIC exists on each instance that resides in VPCs.

      • For instances of the classic network type, eth1 specifies the public NIC.

    • state: You can set this parameter to TCP_TOTAL or ESTABLISHED.

      • TCP_TOTAL specifies the total number of TCP connections.

      • ESTABLISHED specifies the number of TCP connections that are established.

eth0

Expressions

array<object>

No

The information about the multi-metric alert rules.

object

No

The expressions that are specified in the multi-metric alert rule.

MetricName

string

No

The metric names in the multi-metric alert rule. Valid values vary based on the metric type.

  • If you set MetricType to custom, the valid values are the metrics that you have.

  • If you set MetricType to system, this parameter has the following valid values:

    • CpuUtilization: the CPU utilization. Unit: %.

    • ConcurrentConnections: the number of concurrent connections.

    • IntranetTx: the outbound traffic over an internal network. Unit: KB/min.

    • IntranetRx: the inbound traffic over an internal network. Unit: KB/min.

    • VpcInternetTx: the outbound traffic over a VPC. Unit: KB/min.

    • VpcInternetRx: the inbound traffic over a VPC. Unit: KB/min.

    • SystemDiskReadBps: the number of bytes read from the system disk per second.

    • SystemDiskWriteBps: the number of bytes written to the system disk per second.

    • SystemDiskReadOps: the read IOPS of the system disk. Unit: counts/s.

    • SystemDiskWriteOps: the write IOPS of the system disk. Unit: counts/s.

    • CpuUtilizationAgent: the CPU utilization. Unit: %.

    • GpuUtilizationAgent: the GPU utilization. Unit: %.

    • GpuMemoryFreeUtilizationAgent: the idle GPU memory usage. Unit: %.

    • GpuMemoryUtilizationAgent: the GPU memory usage. Unit: %.

    • MemoryUtilization: the memory usage. Unit: %.

    • LoadAverage: the average system load.

    • TcpConnection: the total number of TCP connections.

    • TcpConnection: the number of established TCP connections.

    • PackagesNetOut: the number of packets sent by the internal NIC. Unit: counts/s.

    • PackagesNetIn: the number of packets received by the internal NIC. Unit: counts/s.

    • PackagesNetOut: the number of packets sent by the public NIC. Unit: counts/s.

    • PackagesNetIn: the number of packets received by the public NIC. Unit: counts/s.

    • EciPodCpuUtilization: the CPU utilization. Unit: %.

    • EciPodMemoryUtilization: the memory usage. Unit: %.

    • LoadBalancerRealServerAverageQps: the QPS of an instance.

For more information, see Event-triggered tasks of the system monitoring type.

CpuUtilization

ComparisonOperator

string

No

The operator for comparing the metric value with the threshold in the multi-metric alert rule. Valid values:

  • If the metric value is greater than or equal to the threshold, set the value to >=.

  • If the metric value is less than or equal to the metric threshold, set the value to <=.

  • If the metric value is greater than the metric threshold, set the value to >.

  • If the metric value is less than the metric threshold, set the value to <.

Default value: >=.

>=

Period

integer

No

The statistical period of the metric data in the multi-metric alert rule. Unit: seconds. Valid values:

  • 15

  • 60

  • 120

  • 300

  • 900

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 aggregation method for metric data in the multi-metric alert rule. Valid values:

  • Average: the average value.

  • Minimum: the minimum value

  • Maximum: the maximum value

Default value: Average.

Average

Threshold

number

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 logical relationship between trigger conditions in the multi-metric alert rule. Valid values:

  • &&: An alert is triggered only if all metrics in the multi-metric alert rule meet the trigger conditions. In this case, an alert is triggered only if the results of all trigger conditions that are specified in the multi-metric alert rule are true.

  • ||: An alert is triggered if one of the metrics in the multi-metric alert rule meets the trigger conditions.

Default value: &&.

&&

Response elements

Element

Type

Description

Example

object

AlarmTaskId

string

The ID of the event-triggered task.

asg-bp1hvbnmkl10vll5****_f95ce797-dc2e-4bad-9618-14fee7d1****

RequestId

string

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.