All Products
Search
Document Center

CloudOps Orchestration Service:Monitor real-time prices and discounts of preemptible instances in a scaling group

Last Updated:Jun 14, 2024

Alibaba Cloud Elastic Compute Service (ECS) provides preemptible instances with a discount of up to 90%. If you configure a preemptible instance template in a scaling group, a preemptible instance is automatically created when a scale-out event of the scaling group is triggered. However, you may worry about price changes of preemptible instances that are automatically scaled out. You may be frustrated if you find that the expenses are out of your price range at specific points in time when you settle your monthly bills. CloudOps Orchestration Service (OOS) provides a simpler solution that allows you to monitor the price changes of instance types in a scaling group and get notified of the price changes at the earliest opportunity. This topic describes how to monitor real-time prices and discounts of preemptible instances in a scaling group.

Procedure

Step 1: Activate OOS

1.1 Log on to the Alibaba Cloud Management Console. Search for CloudOps Orchestration Service and click CloudOps Orchestration Service that appears to go to the welcome page of OOS.

1.2 In the left-side navigation pane, choose Automated Task > Scheduled O&M.

No additional fee is charged when you activate OOS.

Step 2: Configure a scheduled task

2.1 Configure the scheduled task type.

On the Scheduled O&M page, click Create. On the Create Scheduled O&M Task page, select Executed Periodically as Scheduled Task Type.

2.2 Configure the execution frequency.

Configure the execution frequency based on your business requirements. Standard crontab expressions are supported. The prices of spot instances do not frequently change within a short period of time. To prevent throttling caused by frequent requests, we recommend that you set an interval that is from 50 minutes to 1 hour. This helps you gain a full insight into price changes. The following figure shows an example.

2.3 Configure the time zone for periodic execution.

Use the default value if you do not have special requirements.

2.4 Configure the end time for periodic execution.

Configure the end time for price monitoring based on your business requirements.

2.5 Preview the upcoming execution time.

Step 3: Select a template

Enter the keyword Alarm or the template name ACS-ECS-AlarmWhenDiscountOrSpotPriceExceedsThresholdByScalingGroup in the search box and click the search icon. Select the ACS-ECS-AlarmWhenDiscountOrSpotPriceExceedsThresholdByScalingGroup template.

Step 4: Configure template parameters

4.1 Select a region.

Select the region of the scaling group in which you want to monitor the price changes of instance types. You can specify only one region. If you want to monitor the price changes of instance types in scaling groups of multiple regions, configure a scheduled O&M task for each region.

4.2 Configure the scaling group.

Enter the ID of the scaling group in which you want to monitor the price changes of instance types. You can enter the IDs of multiple scaling groups.

4.3 Configure the monitoring task type.

Two types of monitoring tasks are supported:

  • Discount: monitors the price changes of instance types in a scaling group based on real-time discounts. For example, ECS instances of the ecs.c6.large type are configured in a scaling group. The original price of the instance type is USD 0.39 per hour and the spot instance price is USD 0.071 per hour. In this case, the discount for the spot instance is 82%, which is calculated based on the following formula: 1 - 0.071/0.39 = 0.82. Select this monitoring task type if you need to receive an alert notification when the discount for the instance type is lower than a specific discount such as 80%.

  • Price: monitors the price changes of instance types in a scaling group based on real-time prices. For example, ECS instances of the ecs.c6.large type are configured in a scaling group. The original price of the instance type is USD 0.39 per hour and the spot instance price is USD 0.071 per hour. Select this monitoring task type if you need to receive an alert notification when the price of the instance type is higher than a specific price such as USD 0.1 per hour.

4.4 Configure a discount or price threshold.

  • If you select Discount as the monitoring type, enter an integer in the Threshold field. Examples:

  • A value of 5 specifies a 95% discount.

  • A value of 11 specifies an 89% discount.

  • A value of 32 specifies a 68% discount.

  • Enter an integer based on the preceding pattern.

  • If you select Price as the monitoring type, enter an hourly price such as 0.1 in the Threshold field.

4.5 Configure the webhook URL for receiving alert notifications.

In this example, a DingTalk chatbot is used.

4.5.1 Add a DingTalk chatbot.

In the DingTalk group in which you want to receive notifications, click the Settings icon in the upper-right corner. In the Group Settings panel, click Bot. In the Robot Management panel, click Add Robot. In the Robot dialog box, click Add Robot. In the Robot dialog box, click Custom. In the Robot details dialog box, click Add. The Add Robot dialog box appears.

4.5.2 In the Security Settings section, add the custom keyword Monitoring. Then, click Finished.

4.5.3 Copy the webhook URL of the chatbot.

4.5.4 Paste the webhook URL to the Webhook field in the OOS console.

4.6 Configure an authorized Resource Access Management (RAM) role.

4.6.1 Click Create Role to go to the RAM console.

4.6.2 Create a RAM role named OOSServiceRole and attach the AliyunECSReadOnlyAccess policy to the RAM role. For more information, see Use RAM to grant permissions to OOS.

4.6.3 Select the RAM role.

After you create the RAM role, return to the OOS console, click the Refresh icon next to the Permissions drop-down list, and then select OOSServiceRole from the drop-down list.

Step 5: Execute the task and verify the alert information

  1. Confirm the execution plan.

  2. Verify the alert information.

To facilitate the verification, we recommend that you set a lower discount or price threshold in Step 4.4. After you verify that you can receive alert notifications, change the threshold to recreate an execution based on your business requirements.