tencent cloud

弹性伸缩

产品简介
产品概述
产品优势
应用场景
使用限制
访问管理
购买指南
快速入门
五分钟创建伸缩方案
步骤1:创建启动配置
步骤2:创建伸缩组
步骤3:创建伸缩策略
教程
创建 Web 服务
创建高性能计算集群
创建请求类服务器
配置高可用业务
启动配置
启动配置概述
创建启动配置
查看启动配置列表
更改启动配置
检测异常
伸缩组
伸缩组概述
创建伸缩组
查看伸缩组列表
修改伸缩组
修改伸缩组绑定的实例
将负载均衡与伸缩组结合
删除伸缩组
创建通知
创建伸缩活动通知
指定通知接收人
扩缩容
生命周期挂钩
管理定时任务
管理告警触发策略
实例健康检查
手动扩容
缩容处理
查看伸缩活动
暂停及恢复扩缩容
指定实例免于缩容
伸缩活动取消
伸缩活动失败
冷却时间说明
监控
监控告警指标
运行状态检查
定时任务
定时任务执行时间说明
故障处理
伸缩组失效
伸缩活动失败
实践教程
为伸缩组设置固定出口 IP
部署弹性 Web 应用服务
设置服务开机启动
客户案例
高性能计算:碳云数据挖掘
API 文档
History
Introduction
API Category
Making API Requests
Scaling Group APIs
Scaling Group Instances APIs
Launch Configuration APIs
Scheduled Action APIs
Alarm Trigger Policy APIs
Notification APIs
Lifecycle Hook APIs
Instance Refresh APIs
Other APIs
Data Types
Error Codes
常见问题
联系我们
词汇表

CreateScalingPolicy

PDF
聚焦模式
字号
最后更新时间: 2025-10-30 21:28:30

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.

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.

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.

    Input Example

    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.

    Input Example

    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.

    Input Example

    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.

    帮助和支持

    本页内容是否解决了您的问题?

    填写满意度调查问卷,共创更好文档体验。

    文档反馈