Domain name for API request: as.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.
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 | No | String | Common Params. This parameter is not required for this API. |
AutoScalingGroupId | Yes | String | Auto scaling group ID. |
ScalingPolicyName | Yes | String | Alarm trigger policy name. |
ScalingPolicyType | No | String | Scaling policy type. Valid values: SIMPLE (default): A simple policyTARGET_TRACKING : A target tracking policy |
AdjustmentType | No | String | The method to adjust the desired capacity after the alarm is triggered. It’s only available when ScalingPolicyType is Simple . Valid values: CHANGE_IN_CAPACITY : Increase or decrease the desired capacity EXACT_CAPACITY : Adjust to the specified desired capacity PERCENT_CHANGE_IN_CAPACITY : Adjust the desired capacity by percentage |
AdjustmentValue | No | Integer | Specifies how to adjust the number of desired capacity when the alarm is triggered. It’s only available when ScalingPolicyType is Simple . Values: AdjustmentType =CHANGE_IN_CAPACITY : Number of instances to add (positive number) or remove (negative number). AdjustmentType =EXACT_CAPACITY : Set the desired capacity to the specified number. It must be ≥ 0. AdjustmentType =PERCENT_CHANGE_IN_CAPACITY : Percentage of instance number. Add instances (positive value) or remove instances (negative value) accordingly. |
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. It’s only available when ScalingPolicyType is Simple . |
PredefinedMetricType | No | String | Preset monitoring item. It’s only available when ScalingPolicyType is TARGET_TRACKING . Valid values: |
TargetValue | No | Integer | Target value. It’s only available when ScalingPolicyType is TARGET_TRACKING . Value ranges: ASG_AVG_CPU_UTILIZATION (in %): [1, 100)ASG_AVG_LAN_TRAFFIC_OUT (in Mbps): >0ASG_AVG_LAN_TRAFFIC_IN (in Mbps): >0ASG_AVG_WAN_TRAFFIC_OUT (in Mbps): >0ASG_AVG_WAN_TRAFFIC_IN (in Mbps): >0 |
EstimatedInstanceWarmup | No | Integer | Instance warm-up period (in seconds). It’s only available when ScalingPolicyType is TARGET_TRACKING . Value range: 0-3600. Default value: 300. |
DisableScaleIn | No | Boolean | Whether to disable scale-in. It’s only available when ScalingPolicyType is TARGET_TRACKING . Valid values: true : Do not scale in false (default): Both scale-out and scale-in can be triggered. |
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. |
Parameter Name | Type | Description |
---|---|---|
AutoScalingPolicyId | String | Alarm trigger policy ID. |
RequestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
The following policy keeps the average CPU utilization of the scaling group stay around 60%, warms up instances added for scale-out for 300 seconds, and allows scale-in.
POST / HTTP/1.1
Host: as.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
}
{
"Response": {
"AutoScalingPolicyId": "asp-ljr51ssq",
"RequestId": "58a8ac17-e864-4bf6-81c7-c5dc63b0057d"
}
}
This example shows you how to increase the desired capacity by one if the average CPU utilization is over 50% within 1 minute for 5 consecutive occurrences.
POST / HTTP/1.1
Host: as.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"
},
"NotificationUserGroupIds": [
"1678"
],
"AdjustmentValue": "1"
}
{
"Response": {
"AutoScalingPolicyId": "asp-iir70sxv",
"RequestId": "fb02c8bd-5f38-4786-91b6-0c6e06a88832"
}
}
This example shows you how to decrease the capacity by 50% if the average MEM utilization is below 35% within 1 minute for 5 consecutive occurrences.
POST / HTTP/1.1
Host: as.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"
},
"NotificationUserGroupIds": [
"1678"
],
"AdjustmentValue": "-50"
}
{
"Response": {
"AutoScalingPolicyId": "asp-f59pppuh",
"RequestId": "116213d6-2269-44cc-af76-c4a8dc7dbdf9"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
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. |
Was this page helpful?