Creating Alarm Triggering Policies

Last updated: 2020-06-04 16:13:12


    This is a legacy API which has been hidden and will no longer be updated. We recommend using the new Auto Scaling API 3.0 which is standardized and faster.

    1. API Description

    This API (CreateScalingPolicy) is used to create an alarm trigger policy.
    Domain for API request:

    1) When adjustmentType is TotalCapacity, it means adjusting the number of CVM instances in the current scaling group to the number specified by adjustmentValue. The value of adjustmentValue must be greater than or equal to 0.

    2) When adjustmentType is QuantityChangeInCapacity or PercentChangeInCapacity, if the value of adjustmentValue is positive, it means increasing instances, and if negative, it means reducing instances.

    3) When adjustmentType is PercentChangeInCapacity, adjustmentValue indicates the percentage of current instances.

    4) A maximum of 100 alarm trigger policies can be created in a scaling group. For more information, refer to Service Limits.

    2. Input Parameters

    The following request parameter list only provides API request parameters. Common request parameters need to be added when the API is called. For more information, refer to Common Request Parameters. The Action field for this API is CreateScalingPolicy.

    Parameter Name Required Type Description
    scalingGroupId Yes String ID of the scaling group for which the alarm trigger policy needs to be created. It can be queried by calling API Query Scaling Group List (DescribeScalingGroup).
    scalingPolicyName Yes String Name of the alarm policy defined by users.
    metric Yes String Parameter metric stipulates the specific scaling policy in json format.
    {"DimensionName": "cpu_usage", "comparisonOperator": "Greater", "threshold": 50, "repeatTimes": 2}
    If cpu usage is greater than 50%, and will be in line with this rule in the next two service periods (5 minutes for each service period), the scaling activity will be triggered to increase or decrease the corresponding CVMs. Click here to view detailed statistical rules
    adjustmentType Yes String Adjustment method of the scaling rule. Only 3 values are available:
    TotalCapacity: Adjusting the number of instances in the current scaling group to the specified number.
    QuantityChangeInCapacity: Increasing or decreasing the instances by specified number.
    PercentChangeInCapacity: Increasing or decreasing instances by specified percentage.
    adjustmentValue Yes Int Adjustment value for the scaling rule. If it is negative, it means decreasing instances. The value ranges of adjustmentValue are as follows:
    TotalCapacity: 0-30
    QuantityChangeInCapacity: -30-30
    PercentChangeInCapacity: -100-100.
    cooldown Yes Int Cooldown period (in seconds), a period of time when the corresponding scaling group is locked after a scaling activity is completed. During this period, this scaling group cannot execute other scaling activities.

    Parameter metric stipulates the specific scaling policy in json format. Its parameters are as follows:

    Parameter Name Required Type Description
    comparisonOperator Yes String Comparison operator. Available values include:
    Greater: Greater than
    EqualOrGreater: Greater than or equal to
    Less: Less than.
    EqualOrLess: Less than or equal to.
    Equal: Equal.
    NotEqual: Not equal.
    dimensionName Yes String Dimension. Available values include:
    cpu_usage: CPU usage.
    mem_usage: Memory usage.
    lan_outtraffic: Outbound bandwidth of the private network.
    lan_intraffic: Inbound bandwidth of the private network.
    threshold Yes Int Alarm threshold:
    cpu_usage: value range [0, 100], unit: %
    mem_usage: value range [0, 100], unit: %
    lan_outtraffic: value range >0, unit: Bps
    lan_intraffic: value range >0, unit: Bps
    repeatTimes No Int Repeated times:
    value range: [1,10], defaults is 3

    3. Output Parameters

    Parameter Name Type Description
    code Int Common error code; 0: Succeeded; other values: Failed. For more information, please refer to Common Error Codes on the Error Code page.
    codeDesc String Error code at business side. If the task succeeds, it will return "Success"; if the task fails, the specific business error reason will be returned.
    message String Module error message description depending on API.
    data Array It contains the list information of scaling rules that were created successfully.

    Parameter data is composed of only one element: scalingPolicyIdSet.

    Parameter Name Type Description
    ScalingPolicyIdSet Array It contains the ID of each scaling rule created.

    4. Error Codes

    The following error codes only include the business logic error codes for this API. For additional common error codes, refer to AS Error Code.

    Error Code Description
    NameDuplicate.ScalingPolicy The scaling rule name already exists
    QuotaExceeded.ScalingPolicy Number of scaling rules allowed to be added has been exceeded
    InvalidParameter.Metric METRIC is configured incorrectly
    InvalidParameter.ScalingPolicyAdjustmenttypeError Incorrect type of scaling action
    InvalidParameter.ScalingPolicyNameError Wrong scaling policy name
    InvalidParameter.AdjustmentValue adjustmentValue of scaling policy is beyond the range

    5. Example
    &<Common request parameters>

    Example of returned result is as below:


    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback