## 1. API Description
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.
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.
## 2. Input Parameters
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see [Common Request Parameters](https://intl.cloud.tencent.com/document/api/377/30987).
| Parameter Name | Required | Type | Description |
|---------|---------|---------|---------|
| Action | Yes | String | [Common Params](https://intl.cloud.tencent.com/document/api/377/30987). The value used for this API: CreateScalingPolicy. |
| Version | Yes | String | [Common Params](https://intl.cloud.tencent.com/document/api/377/30987). The value used for this API: 2018-04-19. |
| Region | Yes | String | [Common Params](https://intl.cloud.tencent.com/document/api/377/30987). For more information, please see the [list of regions](https://intl.cloud.tencent.com/document/api/377/30987#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8) supported by the product. |
| AutoScalingGroupId | Yes | String | Auto scaling group ID. |
| ScalingPolicyName | Yes | String | Alarm trigger policy name. |
| AdjustmentType | Yes | String | The method to adjust the desired number of instances after the alarm is triggered. Value range:
CHANGE_IN_CAPACITY: Increase or decrease the desired number of instances EXACT_CAPACITY: Adjust to the specified desired number of instances PERCENT_CHANGE_IN_CAPACITY: Adjust the desired number of instances by percentage |
| AdjustmentValue | Yes | Integer | The adjusted value of desired number of instances after the alarm is triggered. Value range:
When AdjustmentType is CHANGE_IN_CAPACITY, if AdjustmentValue is a positive value, some new instances will be added after the alarm is triggered, and if it is a negative value, some existing instances will be removed after the alarm is triggered When AdjustmentType is EXACT_CAPACITY, the value of AdjustmentValue is the desired number of instances after the alarm is triggered, which should be equal to or greater than 0 When AdjustmentType is PERCENT_CHANGE_IN_CAPACITY, if AdjusmentValue (in %) is a positive value, new instances will be added by percentage after the alarm is triggered; if it is a negative value, existing instances will be removed by percentage after the alarm is triggered. |
| MetricAlarm | Yes | [MetricAlarm](https://intl.cloud.tencent.com/document/api/377/31018#MetricAlarm) | Alarm monitoring metric. |
| Cooldown | No | Integer | Cooldown period in seconds. Default value: 300 seconds. |
| NotificationUserGroupIds.N | No | Array of String | This parameter is diused. Please use [CreateNotificationConfiguration](https://intl.cloud.tencent.com/document/api/377/33185?from_cn_redirect=1) 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, which is returned for each request. RequestId is required for locating a problem.|
## 4. Example
### Example1 Increasing the desired capacity by one if the average CPU utilization is over 50% within 1 minute for 5 consecutive occurrences
#### Input Example
```
POST / HTTP/1.1
Host: as.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateScalingPolicy
{
"AutoScalingGroupId": "asg-12wjuh0s",
"Cooldown": "60",
"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"
}
```
#### Output Example
```
{
"Response": {
"AutoScalingPolicyId": "asp-iir70sxv",
"RequestId": "fb02c8bd-5f38-4786-91b6-0c6e06a88832"
}
}
```
### Example2 Removing 50% instances if the average memory utilization is below 35% within 1 minute for 5 consecutive occurrences
#### Input Example
```
POST / HTTP/1.1
Host: as.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateScalingPolicy
{
"AutoScalingGroupId": "asg-12wjuh0s",
"Cooldown": "300",
"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"
}
```
#### Output Example
```
{
"Response": {
"AutoScalingPolicyId": "asp-f59pppuh",
"RequestId": "116213d6-2269-44cc-af76-c4a8dc7dbdf9"
}
}
```
## 5. Developer Resources
### SDK
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
* [Tencent Cloud SDK 3.0 for Python](https://github.com/TencentCloud/tencentcloud-sdk-python-intl-en/blob/master/tencentcloud/as/v20180419/as_client.py)
* [Tencent Cloud SDK 3.0 for Java](https://github.com/TencentCloud/tencentcloud-sdk-java-intl-en/blob/master/src/main/java/com/tencentcloudapi/as/v20180419/AsClient.java)
* [Tencent Cloud SDK 3.0 for PHP](https://github.com/TencentCloud/tencentcloud-sdk-php-intl-en/blob/master/src/TencentCloud/As/V20180419/AsClient.php)
* [Tencent Cloud SDK 3.0 for Go](https://github.com/TencentCloud/tencentcloud-sdk-go-intl-en/blob/master/tencentcloud/as/v20180419/client.go)
* [Tencent Cloud SDK 3.0 for NodeJS](https://github.com/TencentCloud/tencentcloud-sdk-nodejs-intl-en/blob/master/tencentcloud/services/as/v20180419/as_client.js)
* [Tencent Cloud SDK 3.0 for .NET](https://github.com/TencentCloud/tencentcloud-sdk-dotnet-intl-en/blob/master/TencentCloud/As/V20180419/AsClient.cs)
* [Tencent Cloud SDK 3.0 for C++](https://github.com/TencentCloud/tencentcloud-sdk-cpp-intl-en/blob/master/as/src/v20180419/AsClient.cpp)
### Command Line Interface
* [Tencent Cloud CLI 3.0](https://intl.cloud.tencent.com/document/product/1013)
## 6. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](https://intl.cloud.tencent.com/document/api/377/31019#.E5.85.AC.E5.85.B1.E9.94.99.E8.AF.AF.E7.A0.81).
| Error Code | Description |
|---------|---------|
| 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. |
| ResourceNotFound.AutoScalingGroupNotFound | The scaling group does not exist. |
Was this page helpful?