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.
Procedure
- 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.
- Click OK.
Cron expressions
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
the 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 | , - / * |
Special characters | Description | Example |
---|---|---|
* |
Indicates all possible values. | In the Month field, an asterisk (* ) indicates every month.
|
, |
Lists enumerated values. | In the Minute field, 5,20 indicates the fifth minute and the twentieth minute.
|
- |
Indicates a range. | In the Minute field, 5-20 indicates that the task is triggered once every minute from the 5th to 20th minute.
|
/ |
Indicates increments. | In the Minute field, 0/15 indicates every 15 minutes starting from the zeroth minute. 3/20 indicates every 20 minutes from the third minute.
|
L |
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
L character.
|
In the Day field, L indicates the last day of a month.
|
W |
The weekday nearest to the specified day of the month. The weekday that the W character finalizes on is in the same month as the given day.
|
If 5W is specified in the Day field and the fifth day of the month falls on Saturday, the
event-triggered task is effective on the nearest weakday Friday, which is the fourth
day of the month. If the fifth day of the month falls on Sunday, the event-triggered
task is effective on the nearest weekday Monday, which is the sixth day of the month.
If the fifth day of the month falls on a weekday, the event-triggered task is effective
on the fifth day of the month.
|
Example | Description |
---|---|
* * * * * |
Is effective all the time. |
* 0-30 1-2 * * |
Is effective between 01:00 and 01:30 and between 02:00 and 02:30 every day. |
* * 0,2 * * |
Is effective between 00:00 and 00:59 and between 02:00 and 02:59 every day. |
* * 1 1/2 * |
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. |
* * 1 L * |
Is effective between 01:00 and 01:59 on the last day of each month. |
* * 1 5W * |
Is effective on different days based on whether the fifth day of each month is a weekday:
|