Event-triggered tasks use CloudMonitor to dynamically manage scaling groups. When metric conditions are met, an event-triggered task triggers a specified scaling rule to automatically adjust the number of instances in a scaling group.
Event-triggered tasks
An event-triggered task monitors specific metrics and collects real-time statistics. When a statistic meets the specified alert conditions, the corresponding scaling rule runs automatically. This keeps metric values within your desired range by adjusting instance counts based on workload changes. Two types of event-triggered tasks are available:
-
System monitoring event-triggered task: A standardized task that allows you to select from predefined system metrics.
-
Custom monitoring event-triggered task: A customizable task that provides a standardized way to integrate your own monitoring system, making the feature more versatile.
Scheduled tasks run a specified scaling rule at a specified time and work well for predictable workloads. For more information, see Overview of scheduled tasks. For unpredictable scenarios such as traffic bursts, event-triggered tasks offer more flexibility by responding to real-time workload changes, adding instances during peak hours to handle increased load and removing instances during off-peak hours to reduce costs.
Limitations
-
If the expected number of instances feature is enabled for a scaling group, no other scaling activities can be performed while a non-parallel scaling activity is in progress. For more information, see Expected number of instances.
-
A scaling rule in its cooldown period rejects trigger requests from an event-triggered task.
After a new ECS or ECI instance is added to a scaling group, it takes several minutes to start, complete configuration, deploy your application, and begin reporting monitoring data. Set an appropriate cooldown period to prevent the scaling rule from being repeatedly triggered before monitoring data from the new instance is available.
-
By default, an event-triggered task has a one-minute silence period (statistical period). This means that after an alert is triggered, the scaling rule is not triggered again within one minute.
Cron expression
When you configure an event-triggered task in the Auto Scaling console, you can set the Effective Period parameter using a Cron expression.
A Cron expression is a space-separated string in the X X X X X format. The five fields represent second, minute, hour, day of the month, and month, respectively. Each field can be a specific value or a special character.
When you configure a Cron expression for an event-triggered task, note the following:
-
Cron expressions use the UTC+0 time zone. When you configure a Cron expression, you must convert your local time to UTC+0. For example, the time zone in China is UTC+8. If you want a task to be effective daily from 01:00 to 02:59 China Standard Time, you must subtract 8 hours. The corresponding Cron expression is
* * 17-18 * *. -
If an alert is triggered outside the effective period of an event-triggered task, the task displays the alert status but does not execute the alert trigger rule.
Table 1. Field values
|
Field |
Required |
Value range |
Special character |
|
Second |
Yes |
0 to 59 |
, - / * |
|
Minute |
Yes |
0 to 59 |
, - / * |
|
Hour |
Yes |
0 to 23 |
, - / * |
|
Day of month |
Yes |
1 to 31 |
, - / * L W |
|
Month |
Yes |
1 to 12 |
, - / * |
Table 2. Special characters
|
Special character |
Description |
Example |
|
|
All possible values in the field. |
In the Month field, |
|
|
A list of enumerated values. |
In the Minute field, |
|
|
A range of values. |
In the Minute field, |
|
|
An increment of a value. |
In the Minute field, |
|
|
Indicates the last day of the month. This character is supported only in the Day of month field. Note
When you specify the |
In the Day of month field, |
|
|
Represents a weekday. The event is triggered on the weekday nearest to the specified day. The |
In the Day of month field, if you specify |
Table 3. Examples
The following table shows how UTC+0 Cron expressions translate to effective times in the UTC+8 time zone. Always define Cron expressions in UTC+0.
|
Example |
Description |
|
|
Effective at all times. |
|
|
Effective from 01:00 to 01:30 and from 02:00 to 02:30 every day. |
|
|
Effective from 00:00 to 00:59 and from 02:00 to 02:59 every day. |
|
|
Effective from 01:00 to 01:59 every two days, starting from the first day of the month. For example, the first two effective periods of each month are 01:00-01:59 on the 1st and 01:00-01:59 on the 3rd. |
|
|
Effective from 01:00 to 01:59 on the last day of each month. |
|
|
The effective time varies based on whether the 5th of the month is a weekday:
|
Table 4. Examples
The following table provides examples of Cron expressions in the UTC+0 time zone. When you set a Cron expression, make sure to convert your local time to UTC+0 if necessary.
Configure event-triggered tasks
The following table describes how to manage event-triggered tasks for a scaling group.
|
Console guide |
Description |
API reference |
|
Create an event-triggered task |
||
|
View event-triggered tasks |
||
|
Modify or delete an event-triggered task |
||
|
Disable or enable an event-triggered task |