CreateAlarm

Updated at:

Creates an event-triggered task.

Operation description

Operation description

  • If you create an event-triggered task of the custom metric type (MetricType=custom), you must first report custom metric data to CloudMonitor. For more information, see Custom metric event-triggered tasks.

  • When you create an event-triggered task, you must specify a metric (MetricName) and configure dimension information (Dimension.N.DimensionKey and Dimension.N.DimensionValue) to determine the aggregation scope of the metric data in the scaling group. For example, you can specify user_id and scaling_group to aggregate the metric data of all ECS instances or ECI instances under the specified user and scaling group.

    • Monitoring metrics for custom metric event-triggered tasks (MetricType=custom) depend on your custom metrics.

    • For more information about monitoring metrics supported by system metric event-triggered tasks (MetricType=system), see System metric event-triggered tasks.

Note

In the dimension information, user_id and scaling_group are automatically populated by the system, while device and state must be manually specified. For more information, see the Dimension.N.DimensionKey and Dimension.N.DimensionValue parameters.

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 ID of the scaling group with which the event-triggered task is associated.

asg-bp18p2yfxow2dloq****

MetricName

string

No

The name of the metric. The valid values vary based on the monitoring type of the event-triggered task:

  • If the event-triggered task is of the custom metric type (MetricType=custom), the valid values are your custom metrics.

  • If the event-triggered task is of the system metric type (MetricType=system), the valid values are as follows:

    • CpuUtilization: the CPU utilization of an ECS instance (%).

    • ConcurrentConnections: the number of concurrent connections to an ECS instance.

    • IntranetTx: the outbound internal network traffic of an ECS instance (Kbit/min).

    • IntranetRx: the inbound internal network traffic of an ECS instance (Kbit/min).

    • VpcInternetTx: the outbound Internet traffic of an ECS instance (Kbit/min).

    • VpcInternetRx: the inbound Internet traffic of an ECS instance (Kbit/min).

    • SystemDiskReadBps: the read bandwidth of the system cloud disk of an ECS instance (Byte/s).

    • SystemDiskWriteBps: the write bandwidth of the system cloud disk of an ECS instance (Byte/s).

    • SystemDiskReadOps: the read IOPS of the system cloud disk of an ECS instance (operations/s).

    • SystemDiskWriteOps: the write IOPS of the system cloud disk of an ECS instance (operations/s).

    • CpuUtilizationAgent: the CPU utilization monitored by the CloudMonitor agent (%).

    • GpuUtilizationAgent: the GPU utilization monitored by the CloudMonitor agent (%).

    • GpuMemoryFreeUtilizationAgent: the percentage of idle GPU memory monitored by the CloudMonitor agent (%).

    • GpuMemoryUtilizationAgent: the GPU memory utilization monitored by the CloudMonitor agent (%).

    • MemoryUtilization: the memory utilization monitored by the CloudMonitor agent (%).

    • LoadAverage: the average system load monitored by the CloudMonitor agent.

    • TcpConnection: the total number of TCP connections monitored by the CloudMonitor agent.

    • TcpConnection: the number of established TCP connections monitored by the CloudMonitor agent.

    • PackagesNetOut: the number of packets sent by the internal network interface controller (NIC) monitored by the CloudMonitor agent (packets/s).

    • PackagesNetIn: the number of packets received by the internal NIC monitored by the CloudMonitor agent (packets/s).

    • PackagesNetOut: the number of packets sent by the public NIC monitored by the CloudMonitor agent (packets/s).

    • PackagesNetIn: the number of packets received by the public NIC monitored by the CloudMonitor agent (packets/s).

    • EciPodCpuUtilization: the CPU utilization (%).

    • EciPodMemoryUtilization: the memory utilization (%).

    • LoadBalancerRealServerAverageQps: the average queries per second (QPS) per backend server in an ALB server group (queries/s).

For more information, see System metric event-triggered tasks.

CpuUtilization

MetricType

string

No

The metric type. Valid values:

  • system: uses system metrics of CloudMonitor.

  • custom: uses custom metrics reported to CloudMonitor.

system

Period

integer

No

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

  • 15

  • 60

  • 120

  • 300

  • 900

Note

A statistical period of 15 seconds is supported only for ECS scaling groups.

Default value: 300.

300

Statistics

string

No

The statistical method for the metric data. Valid values:

  • Average

  • Minimum

  • Maximum

Default value: Average.

Average

Threshold

number

No

The threshold of the monitoring metrics. A scaling rule is triggered when the threshold expression is met for the specified number of times.

80.0

ComparisonOperator

string

No

The comparison operator used to compare the statistical value of the metric with the threshold. Valid values:

  • Note

    =: The statistical value of the metric is greater than or equal to the threshold.

  • <=: The statistical value of the metric is less than or equal to the threshold.

  • Note

    : The statistical value of the metric is greater than the threshold.

  • <: The statistical value of the metric is less than the threshold.

Default value: >=.

>=

EvaluationCount

integer

No

The number of times that the threshold expression must be met to trigger a scaling rule. For example, if this parameter is set to 3, the scaling rule is triggered when the average CPU utilization is greater than or equal to 80% for three consecutive times.

Default value: 3.

3

GroupId

integer

No

The ID of the CloudMonitor application group to which the custom metric belongs. This parameter is required only when the metric type is custom.

4055401

Effective

string

No

The effective period of the event-triggered task. By default, the task is effective at all times.

This parameter follows a cron expression. The default format is X X X X X ?, where:

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

  • ?: indicates that no value is specified.

Note

The specified value defaults to the UTC+8 time zone. You can add the time zone information TZ=+yy before the cron expression to specify a time zone, where y represents the time zone offset. For example, TZ=+00 * * 1-2 * * ? indicates that the event-triggered task is effective between 01:00 and 02:59 every day in the UTC+0 time zone.

Examples:

  • * * * * * ?: The task is effective at all times.

  • * * 17-18 * * ?: The task is effective between 17:00 and 18:59 every day in the UTC+8 time zone.

  • TZ=+00 * * 1-2 * * ?: The task is effective between 01:00 and 02:59 every day in the UTC+0 time zone.

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

AlarmAction

array

No

The unique identifier of the scaling rule associated with the event-triggered task.

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

string

No

The unique identifier of the scaling rule associated with the event-triggered task.

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

Dimension

array<object>

No

The list of dimensions associated with the metric.

object

No

The list of dimensions associated with the metric.

DimensionKey

string

No

The key of the dimension associated with the metric. The valid values vary based on the monitoring type of the event-triggered task:

  • If the event-triggered task is of the custom metric type (MetricType=custom), the valid values are not limited and can be specified by you.

  • If the event-triggered task is of the system metric type (MetricType=system), the valid values are as follows:

    • user_id: your account ID.

    • scaling_group: the monitored scaling group.

    • device: the type of the network interface controller (NIC).

    • state: the state of the TCP connection.

    • rulePool: the ALB server group specified for the QPS monitoring metrics.

device

DimensionValue

string

No

The value of the dimension associated with the metric. The valid values are determined by Dimension.N.DimensionKey:

  • If Dimension.N.DimensionKey is a custom value, which means the event-triggered task is of the custom metric type (MetricType=custom), the valid values of this parameter are not limited and can be specified by you.

  • If Dimension.N.DimensionKey is a system-specified value, which means the event-triggered task is of the system metric type (MetricType=system), the valid values of this parameter are as follows:

    • user_id: automatically populated by the system.

    • scaling_group: automatically populated by the system.

    • device:

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

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

    • state:

      • TCP_TOTAL: the total number of TCP connections.

      • ESTABLISHED: the number of established TCP connections.

    • rulePool: the ID of the ALB server group. Example: sgp-xxxxx.

eth0

Expression

array<object>

No

The information about the multi-metric alert rule.

object

No

The information about the multi-metric alert rule.

MetricName

string

No

The name of the monitoring metrics for the multi-metric alert rule. The valid values vary based on the monitoring type of the event-triggered task:

  • If the event-triggered task is of the custom metric type (MetricType=custom), the valid values are your custom metrics.

  • If the event-triggered task is of the system metric type (MetricType=system), the valid values are as follows:

    • CpuUtilization: the CPU utilization of an ECS instance (%).

    • ConcurrentConnections: the number of concurrent connections to an ECS instance.

    • IntranetTx: the outbound internal network traffic of an ECS instance (Kbit/min).

    • IntranetRx: the inbound internal network traffic of an ECS instance (Kbit/min).

    • VpcInternetTx: the outbound Internet traffic of an ECS instance (Kbit/min).

    • VpcInternetRx: the inbound Internet traffic of an ECS instance (Kbit/min).

    • SystemDiskReadBps: the read bandwidth of the system cloud disk of an ECS instance (Byte/s).

    • SystemDiskWriteBps: the write bandwidth of the system cloud disk of an ECS instance (Byte/s).

    • SystemDiskReadOps: the read IOPS of the system cloud disk of an ECS instance (operations/s).

    • SystemDiskWriteOps: the write IOPS of the system cloud disk of an ECS instance (operations/s).

    • CpuUtilizationAgent: the CPU utilization monitored by the CloudMonitor agent (%).

    • GpuUtilizationAgent: the GPU utilization monitored by the CloudMonitor agent (%).

    • GpuMemoryFreeUtilizationAgent: the percentage of idle GPU memory monitored by the CloudMonitor agent (%).

    • GpuMemoryUtilizationAgent: the GPU memory utilization monitored by the CloudMonitor agent (%).

    • MemoryUtilization: the memory utilization monitored by the CloudMonitor agent (%).

    • LoadAverage: the average system load monitored by the CloudMonitor agent.

    • TcpConnection: the total number of TCP connections monitored by the CloudMonitor agent.

    • TcpConnection: the number of established TCP connections monitored by the CloudMonitor agent.

    • PackagesNetOut: the number of packets sent by the internal network interface controller (NIC) monitored by the CloudMonitor agent (packets/s).

    • PackagesNetIn: the number of packets received by the internal network interface controller (NIC) monitored by the CloudMonitor agent (packets/s).

    • PackagesNetOut: the number of packets sent by the public network interface controller (NIC) monitored by the CloudMonitor agent (packets/s).

    • PackagesNetIn: the number of packets received by the public network interface controller (NIC) monitored by the CloudMonitor agent (packets/s).

    • EciPodCpuUtilization: the CPU utilization (%).

    • EciPodMemoryUtilization: the memory utilization (%).

    • LoadBalancerRealServerAverageQps: the average queries per second (QPS) per backend server in an ALB server group (queries/s).

For more information, see System metric event-triggered tasks.

CpuUtilization

ComparisonOperator

string

No

The comparison operator used to compare the statistical value of the metric with the threshold in the multi-metric alert rule. Valid values:

  • Note

    =: The statistical value of the metric is greater than or equal to the threshold.

  • <=: The statistical value of the metric is less than or equal to the threshold.

  • Note

    : The statistical value of the metric is greater than the threshold.

  • <: The statistical value of the metric is less than the threshold.

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

A statistical period of 15 seconds is supported only for ECS scaling groups. Default value: 300.

900

Statistics

string

No

The statistical method for the metric data in the multi-metric alert rule. Valid values:

  • Average

  • Minimum

  • Maximum

Default value: Average.

Average

Threshold

number

No

The threshold of the monitoring metrics in the multi-metric alert rule. A scaling rule is triggered when the threshold expression is met for the specified number of times.

40.0

ExpressionsLogicOperator

string

No

The logical operator between multiple monitoring metrics alert conditions. Valid values:

  • &&: An alert is triggered only when all monitoring metrics meet the alert conditions. That is, an alert is triggered only when all expressions in the multi-metric alert rule evaluate to true.

  • ||: An alert is triggered when any one of the monitoring metrics meets the alert condition.

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 request ID.

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.