1. API Description
Domain name for API request: as.intl.tencentcloudapi.com.
This API (CreateScalingPolicy) is used to create an alarm trigger policy.
A maximum of 20 requests can be initiated per second for this API.
We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
| Parameter Name |
Required |
Type |
Description |
| Action |
Yes |
String |
Common Params. The value used for this API: CreateScalingPolicy. |
| Version |
Yes |
String |
Common Params. The value used for this API: 2018-04-19. |
| Region |
Yes |
String |
Common Params. For more information, please see the list of regions supported by the product. |
| AutoScalingGroupId |
Yes |
String |
Scaling group ID. obtain the scaling group ID by logging in to the console (https://console.tencentcloud.com/autoscaling/group) or calling the api DescribeAutoScalingGroups (https://www.tencentcloud.com/document/api/377/20438?from_cn_redirect=1), and retrieve AutoScalingGroupId from the returned information. |
| ScalingPolicyName |
Yes |
String |
The Alarm policy name must be unique in your account. the name length cannot exceed 60 characters. the name only supports chinese, english, digits, underscores, hyphens, and decimal points. |
| ScalingPolicyType |
No |
String |
Alarm trigger policy type. default: SIMPLE. valid values:.
SIMPLE: a simple policy..
TARGET_TRACKING: a target tracking policy.. |
| AdjustmentType |
No |
String |
After an Alarm is triggered, specifies the method for modifying the expected number of instances. required in the scenario of simple policies. valid values:. CHANGE_IN_CAPACITY: increase or decrease the expected number of instances. EXACT_CAPACITY: adjust to the expected number of instances. PERCENT_CHANGE_IN_CAPACITY: adjust expected instance number by percent. |
| AdjustmentValue |
No |
Integer |
Adjustment value for the expected number of instances after an Alarm is triggered, which is applicable only to simple policies and required in simple policy scenarios. When AdjustmentType is CHANGE_IN_CAPACITY, a positive AdjustmentValue indicates an increase IN instances after Alarm trigger, while a negative value indicates a decrease IN instances after Alarm trigger.. When AdjustmentType is set to EXACT_CAPACITY, the value of AdjustmentValue indicates the new desired number of instances after the Alarm is triggered. it must be at least 0.. When AdjustmentType is set to PERCENT_CHANGE_IN_CAPACITY, a positive value of AdjustmentValue indicates an increase in the number of instances by a percentage after the alarm is triggered, while a negative value indicates a decrease in the number of instances by a percentage after the alarm is triggered. Unit: %. |
| Cooldown |
No |
Integer |
Cooldown period (in seconds). This parameter is only applicable to a simple policy. Default value: 300. |
| MetricAlarm |
No |
MetricAlarm |
Alarm monitoring metric, apply only to simple policies, required in the scenario of simple policy. |
| PredefinedMetricType |
No |
String |
Predefined monitoring item, applicable only to target tracking policies. required in the scenario. value range:. ASG_AVG_CPU_UTILIZATION: average cpu utilization. ASG_AVG_LAN_TRAFFIC_OUT: specifies the average outbound private network bandwidth.. ASG_AVG_LAN_TRAFFIC_IN: average inbound private network bandwidth. ASG_AVG_WAN_TRAFFIC_OUT: specifies the average outbound public network bandwidth.. ASG_AVG_WAN_TRAFFIC_IN: average inbound public network bandwidth |
| TargetValue |
No |
Integer |
Target value, applicable only to the target tracking policy, required in the scenario. ASG_AVG_CPU_UTILIZATION: value range: [1, 100); unit: %.. ASG_AVG_LAN_TRAFFIC_OUT: value range: > 0; unit: Mbps.. ASG_AVG_LAN_TRAFFIC_IN: value range: > 0; unit: Mbps.. ASG_AVG_WAN_TRAFFIC_OUT: value range: > 0; unit: Mbps.. ASG_AVG_WAN_TRAFFIC_IN: value range: > 0; unit: Mbps. |
| EstimatedInstanceWarmup |
No |
Integer |
Instance warm-up period (in seconds). It is only available when ScalingPolicyType is TARGET_TRACKING. Value range: 0-3600. Default value: 300. |
| DisableScaleIn |
No |
Boolean |
Whether to disable scale-in, which is applicable only to target tracking policies. Default value: false. Valid values: true: Target tracking policies trigger only scale-out.false: Target tracking policies trigger both scale-out and scale-in. |
| NotificationUserGroupIds.N |
No |
Array of String |
This parameter is diused. Please use CreateNotificationConfiguration instead. Notification group ID, which is the set of user group IDs. |
3. Output Parameters
| Parameter Name |
Type |
Description |
| AutoScalingPolicyId |
String |
Alarm trigger policy ID. |
| RequestId |
String |
The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
4. Example
Example1 Creating a Simple Policy: Average CPU Utilization
This example shows you how to increase the expected instance number by 1 when the average CPU utilization exceeds 50% for five consecutive times within 1 minute.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateScalingPolicy
<Common request parameters>
{
"AutoScalingGroupId": "asg-12wjuh0s",
"Cooldown": 60,
"ScalingPolicyType": "SIMPLE",
"ScalingPolicyName": "cpu_policy_test",
"AdjustmentType": " CHANGE_IN_CAPACITY",
"MetricAlarm": {
"Period": 60,
"ContinuousTime": 5,
"ComparisonOperator": "GREATER_THAN",
"Statistic": "AVERAGE",
"Threshold": 50,
"MetricName": "CPU_UTILIZATION"
},
"AdjustmentValue": 1
}
Output Example
{
"Response": {
"AutoScalingPolicyId": "asp-iir70sxv",
"RequestId": "fb02c8bd-5f38-4786-91b6-0c6e06a88832"
}
}
Example2 Creating a Simple Policy: Average Memory Utilization
This example shows you how to decrease the expected instance number by 50% when the average CPU utilization falls below 35% for five consecutive times within 1 minute.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateScalingPolicy
<Common request parameters>
{
"AutoScalingGroupId": "asg-12wjuh0s",
"Cooldown": 300,
"ScalingPolicyType": "SIMPLE",
"ScalingPolicyName": "mem_policy_test",
"AdjustmentType": " PERCENT_CHANGE_IN_CAPACITY",
"MetricAlarm": {
"Period": 60,
"ContinuousTime": 5,
"ComparisonOperator": "LESS_THAN",
"Statistic": "AVERAGE",
"Threshold": 50,
"MetricName": "MEM_UTILIZATION"
},
"AdjustmentValue": -50
}
Output Example
{
"Response": {
"AutoScalingPolicyId": "asp-f59pppuh",
"RequestId": "116213d6-2269-44cc-af76-c4a8dc7dbdf9"
}
}
Example3 Creating a Target Tracking Policy: Average CPU Utilization
This example shows you how to keep the average CPU utilization of the scaling group close to 60%, how to set the parameter for scale-out instance preheating to 300 after the alarm is triggered, and how to set the disabling scale-in parameter value to false.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateScalingPolicy
<Common request parameters>
{
"AutoScalingGroupId": "asg-9dn1a5y6",
"ScalingPolicyName": "cpu_target_tracking_test",
"ScalingPolicyType": "TARGET_TRACKING",
"PredefinedMetricType": "ASG_AVG_CPU_UTILIZATION",
"EstimatedInstanceWarmup": 300,
"DisableScaleIn": false,
"TargetValue": 60
}
Output Example
{
"Response": {
"AutoScalingPolicyId": "asp-ljr51ssq",
"RequestId": "58a8ac17-e864-4bf6-81c7-c5dc63b0057d"
}
}
5. Developer Resources
SDK
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
Command Line Interface
6. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code |
Description |
| InternalError.CallMonitorError |
Monitor API call failed. |
| InternalError.CallNotificationError |
The notification service API call failed. |
| InternalError.RequestError |
An internal request error occurred. |
| InvalidParameter.ActionNotFound |
Invalid Action request. |
| InvalidParameterValue.InvalidAutoScalingGroupId |
Invalid scaling group ID. |
| InvalidParameterValue.InvalidNotificationUserGroupId |
The notification group ID should be a numeric string. |
| InvalidParameterValue.LimitExceeded |
The value exceeds the limit. |
| InvalidParameterValue.Range |
The value is outside the specified range. |
| InvalidParameterValue.ScalingPolicyNameDuplicate |
The alarm policy name already exists. |
| InvalidParameterValue.ThresholdOutOfRange |
The specified threshold must be within the valid range. |
| InvalidParameterValue.TooLong |
Too many values. |
| InvalidParameterValue.UserGroupIdNotFound |
The user group does not exist. |
| LimitExceeded.QuotaNotEnough |
You are short of the quota. |
| LimitExceeded.TargetTrackingScalingPolicy |
Only one target tracking policy can be created for a scaling group. |
| ResourceNotFound.AutoScalingGroupNotFound |
The scaling group does not exist. |