All Products
Search
Document Center

Auto Scaling:ModifyAlarm

Last Updated:Apr 30, 2024

Modifies event-triggered tasks. If your event-triggered task cannot meet your business requirements, you can call the ModifyAlarm operation to modify the event-triggered task. This eliminates the need for creating new event-triggered tasks and saves time and costs.

Usage notes

  • 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, Dimension.N.DimensionKey, and Dimension.N.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 Elastic Compute Service (ECS) instances or elastic container instances in a scaling group within an Alibaba Cloud account.

    • If you modify an event-triggered task of the custom monitoring type, you can specify only custom metrics in the task.

    • If you modify 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

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

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

ModifyAlarm

The operation that you want to perform. Set the value to ModifyAlarm.

RegionId

String

Yes

cn-qingdao

The region ID of the event-triggered task.

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 metric name. The valid values of MetricName vary based on the value of MetricType.

  • If you set MetricType to custom, the valid values of MetricName are your custom metrics.

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

    • CpuUtilization: the CPU utilization. Unit: %.

    • 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 network interface controller (NIC). Unit: counts/s.

    • PackagesNetIn: the number of packets received by the 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.

MetricType

String

No

system

The metric type. Valid values:

  • system: system metrics of CloudMonitor

  • custom: custom metrics that are published to CloudMonitor

Period

Integer

No

300

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.

Statistics

String

No

Average

The method that you want to use to aggregate the metric data. Valid values:

  • Average

  • Minimum

  • Maximum

Threshold

Float

No

80

The threshold of the metric. If the threshold is reached the specified number of times within the statistical period, a scaling rule is executed.

ComparisonOperator

String

No

>=

The operator that you want to use to compare the metric value and 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 threshold, set the value to <=.

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

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

EvaluationCount

Integer

No

3

The number of consecutive times that 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 times in a row before a scaling rule is executed.

GroupId

Integer

No

4055401

The ID of the CloudMonitor application group to which the custom metric belongs. This parameter is required only if you set MetricType to custom.

Effective

String

No

TZ=+00 * * 1-2 * * ?

The effective period of the event-triggered task.

The Effective value 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, the value of this parameter is specified in UTC+8. You can specify the time zone before a cron expression in the TZ=+yy format. y indicates the time zone. For example, TZ=+00 * * 1-2 * * ? specifies that the event-triggered task is in effect between 01:00:00 and 02:59:00 (UTC+0) every day.

Examples:

  • * * * * * ? : The event-triggered task is in effect at all times.

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

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

AlarmAction.N

String

No

ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp163l21e07uhn****

The unique identifier of scaling rule N that you want to associate with the event-triggered task.

Dimension.N.DimensionKey

String

No

device

The key of dimension N that you want to associate with the metric. The valid values of Dimension.N.DimensionKey vary based on the value of MetricType.

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

  • If you set MetricType to system, Dimension.N.DimensionKey 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 type of the NIC.

    • state: the status of the TCP connection

Dimension.N.DimensionValue

String

No

eth0

The value of dimension N that you want to associate with the metric. The valid values of Dimension.N.DimensionValue vary based on the value of Dimension.N.DimensionKey.

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

  • If you set MetricType to system, Dimension.N.DimensionValue 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.

Expression.N.MetricName

String

No

CpuUtilization

The names of the metrics in the multi-metric alert rule. The valid values of this parameter vary based on the metric type.

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

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

    • CpuUtilization: the CPU utilization. Unit: %.

    • 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 NIC. Unit: counts/s.

    • PackagesNetIn: the number of packets received by the 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.

Expression.N.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:

  • 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 threshold, set the value to <=.

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

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

Default value: >=.

Expression.N.Period

Integer

No

300

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 the value of this parameter to 15 seconds only for scaling groups of the ECS type.

Default value: 300.

Expression.N.Statistics

String

No

Average

The method that you want to use to aggregate the metric data in the multi-metric alert rule. Valid values:

  • Average

  • Minimum

  • Maximum

Expression.N.Threshold

Float

No

40.0

The thresholds of the metric values in the multi-metric alert rule. If the thresholds are reached the specified number of times within the statistical period, a scaling rule is executed.

ExpressionsLogicOperator

String

No

&&

The alert triggering logic of the multi-metric alert rule. Valid values:

  • &&: An alert is triggered only if all trigger conditions in the multi-metric alert rule are met. That is, an alert is triggered only if the results of all expressions defined in the multi-metric alert rule are true.

  • ||: An alert is triggered if one of the trigger conditions in the multi-metric alert rule 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 request ID.

Examples

Sample requests

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 success 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, see Service error codes.