This topic describes how to create an event-triggered task associated with a CloudMonitor metric in response to emergent or unpredictable business changes. After you create and enable an event-triggered task, Auto Scaling collects data for the specified metric in real time and triggers an alert when the specified condition is met. Then, Auto Scaling executes the scaling rule that is specified in the event-triggered task to dynamically scale ECS instances in the scaling group during the effective period of the event-triggered task.
- Log on to the Auto Scaling console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Select a monitoring type for the event-triggered task.
- If you want to use metrics defined by the system, click the System Monitoring tab.
- If you want to use custom metrics, click the Custom Monitoring tab.
- Click Create Event-triggered Task.
- In the dialog box that appears, configure parameters for the monitoring task.
- Enter a task name. The name must be 2 to 64 characters in length and can contain periods (.), underscores (_), and hyphens (-). It must start with a letter or a digit.
- Enter a task description.
- Select the resource to be monitored. The resource to be monitored is a scaling group.
- Configure monitoring information based on the monitoring type.
- System monitoring event-triggered task: You must select a metric defined by the system. For information about metrics supported by the system, see Event-triggered tasks for system monitoring.
- Custom monitoring event-triggered task: You must select an application group, a metric, and a dimension that are preconfigured in CloudMonitor. For more information about how to use custom metrics, see Custom monitoring event-triggered tasks.
- Set the reference period. You can set the reference period to 1 Minute, 2 Minutes, 5 Minutes, or 15 Minutes. Auto Scaling collects, summarizes, and compares data based on the specified reference period. The shorter the reference period is, the more frequently alerts are triggered. Set the reference period based on your business requirements.
- Configure the condition. The condition is a rule that specifies whether the CloudMonitor metric value exceeds the threshold range. You can specify the condition based on the average, minimum, or maximum value. For example, if you want alerts to be triggered when the CPU utilization exceeds 80%, you can configure the condition by using one of the following methods:
- Average: Alerts are triggered when the average CPU utilization of all the ECS instances in the scaling group exceeds 80%.
- Maximum: Alerts are triggered when the highest CPU utilization of all the ECS instances in the scaling group exceeds 80%.
- Minimum: Alerts are triggered when the lowest CPU utilization of all the ECS instances in the scaling group exceeds 80%.
- Specify the number of times that the condition is met before an alert is triggered.
Auto Scaling counts the number of times that the condition is met. When the number reaches the value of Trigger After, Auto Scaling triggers an alert and executes the scaling rule specified in the event-triggered task.
- Set the effective period. During the effective period, Auto Scaling executes the scaling rule specified in the event-triggered task when alerts are triggered. If alerts are triggered beyond the effective period, Auto Scaling does not execute the scaling rule.
- Not Set: The event-triggered task is effective all the time.
- Cron Expression: The event-triggered task is effective only within the time range specified by the cron expression. For information about cron expressions, see Cron expressions.
- Set the trigger rule. Select the scaling rule to be executed when the condition is met for the specified number of times. You can select only a scaling rule that belongs to the monitored scaling group.
- Enter a task name.
- Click OK.
A cron expression is a string that represents a schedule. The string consists of multiple
fields that are separated by spaces and describe individual details of the schedule.
An event-triggered task supports a cron expression that consists of five fields in
X X X X X format.
X indicates a placeholder for a field. Each field in a cron expression represents seconds,
minutes, hours, day of month, and months. Each field can be a definite value or a
special character that has logical meaning.
* * 17-18 * *.
|Field||Required||Value range||Special character|
|Second||Yes||0~59||, - / *|
|Minute||Yes||0~59||, - / *|
|Hour||Yes||0~23||, - / *|
|Day||Yes||1~31||, - / * L W|
|Month||Yes||1~12||, - / *|
||Indicates all possible values.||In the Month field, an asterisk (
||Lists enumerated values.||In the Minute field,
||Indicates a range.||In the Minute field,
||Indicates increments.||In the Minute field,
||Indicates last. Only the Day field supports this character.
Note To avoid logic errors, do not specify a list or range when you use the
|In the Day field,
||The weekday nearest to the specified day of the month. The weekday that the
||Is effective all the time.|
||Is effective between 01:00 and 01:30 and between 02:00 and 02:30 every day.|
||Is effective between 00:00 and 00:59 and between 02:00 and 02:59 every day.|
||Is effective between 01:00 and 01:59 every two days staring from the first day of each month. For example, the first two effective time ranges of each month are between 01:00 and 01:59 on the first day of each month and between 01:00 and 01:59 on the third day of each month.|
||Is effective between 01:00 and 01:59 on the last day of each month.|
||Is effective on different days based on whether the fifth day of each month is a weekday: