Updated on 2024-12-10 GMT+08:00

Viewing Auto Scaling Policies

Function

This API is used to view all auto scaling policies of a specified cluster.

Constraints

None

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.

URI

GET /v2/{project_id}/autoscaling-policy/{cluster_id}

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Explanation

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Constraints

N/A

Value range

The value must consist of 1 to 64 characters. Only letters and digits are allowed.

Default value

N/A

cluster_id

Yes

String

Explanation

Cluster ID. If this parameter is specified, the latest metadata of the cluster that has been patched will be obtained. For details about how to obtain the cluster ID, see Obtaining a Cluster ID.

Constraints

N/A

Value range

The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-).

Default value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameter

Parameter

Type

Description

[Array element]

Array of AutoScalingPolicyV2 objects

Explanation

The auto scaling policy list. For details, see Table 3.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 3 AutoScalingPolicyV2

Parameter

Type

Description

node_group_name

String

Explanation

Node group name.

Constraints

N/A

Value range

N/A

Default value

N/A

resource_pool_name

String

Explanation

Pool name.

Constraints

If the cluster version does not support auto scaling for a specified resource pool, set this parameter to default.

Value range

The value can contain only letters, digits, underscores (_), and hyphens (-).

Default value

N/A

auto_scaling_policy

AutoScalingPolicyInfo object

Explanation

The auto scaling policy. For details, see Table 4.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 4 AutoScalingPolicyInfo

Parameter

Type

Description

auto_scaling_enable

Boolean

Explanation

Whether to enable the auto scaling policy.

Constraints

N/A

Value range

  • true: Enable the auto scaling rule.
  • false: Disable the autoscaling rule.

Default value

N/A

min_capacity

Integer

Explanation

Minimum number of nodes left in the node group.

Constraints

N/A

Value range

0-500

Default value

N/A

max_capacity

Integer

Explanation

Maximum number of nodes in the node group.

Constraints

N/A

Value range

0-500

Default value

N/A

resources_plans

Array of ResourcesPlan objects

Explanation

Resource plan list. If this parameter is left blank, the resource plan is disabled.

Constraints

When auto_scaling_enable is set to true, either this parameter or rules must be configured. For details about this parameter, see Table 5.

Value range

N/A

Default value

N/A

rules

Array of Rule objects

Explanation

Auto scaling rules.

Constraints

When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. The number of records cannot exceed 10. For details, see Table 6.

Value range

N/A

Default value

N/A

tags

Array of Tag objects

Explanation

Auto scaling tags. For details, see Table 8. .

Constraints

The number of records cannot exceed 100.

Value range

N/A

Default value

N/A

Table 5 ResourcesPlan

Parameter

Type

Description

period_type

String

Explanation

Cycle type of a resource plan. This parameter can be set to daily only.

Constraints

N/A

Value range

N/A

Default value

N/A

start_time

String

Explanation

Start time of a resource plan. The value is in the format of hour:minute, indicating that the time ranges from 00:00 to 23:59.

Constraints

N/A

Value range

N/A

Default value

N/A

end_time

String

Explanation

End time of a resource plan. The format is the same as that of start_time.

Constraints

The value cannot be earlier than the start_time, and the interval between start_time and start_time cannot be less than 30 minutes.

Value range

N/A

Default value

N/A

min_capacity

Integer

Explanation

Minimum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Value range

0-500

Default value

N/A

max_capacity

Integer

Explanation

Maximum number of the preserved nodes in a node group in a resource plan.

Constraints

N/A

Value range

0-500

Default value

N/A

effective_days

Array of strings

Explanation

Effective date of a resource plan. If this parameter is left blank, it indicates that the resource plan takes effect every day. The options are as follows:

MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY

Constraints

N/A

Value range

N/A

Default value

N/A

Table 6 Rule

Parameter

Type

Description

name

String

Explanation

Name of an auto scaling rule.

Constraints

N/A

Value range

The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-).

Rule names must be unique in a node group.

Default value

N/A

description

String

Explanation

Description about an auto scaling rule.

Constraints

N/A

Value range

The value can contain 0 to 1024 characters.

Default value

N/A

adjustment_type

String

Explanation

Adjustment type of an auto scaling rule.

Constraints

N/A

Value range

  • scale_out: cluster scale-out
  • scale_in: cluster scale-in

Default value

N/A

cool_down_minutes

Integer

Explanation

Cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute.

Constraints

N/A

Value range

The value ranges from 0 to 10080. 10080 indicates the number of minutes in a week.

Default value

N/A

scaling_adjustment

Integer

Explanation

Number of nodes that can be adjusted once.

Constraints

N/A

Value range

1-100

Default value

N/A

trigger

Trigger object

Explanation

The condition for triggering a rule. For details, see Table 7.

Constraints

N/A

Value range

N/A

Default value

N/A

Table 7 Trigger

Parameter

Type

Description

metric_name

String

Explanation

Metric name. This triggering condition makes a judgment according to the value of the metric.

Constraints

N/A

Value range

For details about the value range, see Auto scaling metrics.

Default value

N/A

metric_value

String

Explanation

Metric threshold to trigger a rule. The value must be an integer or a number with two decimal places.

Constraints

N/A

Value range

Only integers or numbers with two decimal places are allowed.

Default value

N/A

comparison_operator

String

Explanation

Metric judgment logic operator.

Constraints

N/A

Value range

  • LT: less than
  • GT: greater than
  • LTOE: less than or equal to
  • GTOE: greater than or equal to

Default value

N/A

evaluation_periods

Integer

Explanation

Number of consecutive five-minute periods, during which a metric threshold is reached

Constraints

N/A

Value range

1-288

Default value

N/A

Table 8 Tag

Parameter

Type

Description

key

String

Explanation

Tag key.

Constraints

N/A

Value range

  • A tag key can contain letters, digits, spaces, and special characters _.:=+-@, but cannot start or end with a space or start with _sys_.
  • The tag key of a resource must be unique.
  • It can contain a maximum of 128 Unicode characters and cannot be an empty string.

Default value

N/A

value

String

Explanation

Tag value.

Constraints

N/A

Value range

  • The value can contain letters, digits, spaces, and special characters _.:=+-@, but cannot start or end with a space or start with _sys_.
  • The value can contain a maximum of 255 Unicode characters and can be an empty string.

Default value

N/A

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Explanation

Error code.

Constraints

N/A

Value range

N/A

Default value

N/A

error_msg

String

Explanation

Error message.

Constraints

N/A

Value range

N/A

Default value

N/A

Example Request

None

Example Response

Status code: 200

Auto scaling policies are displayed.

{
  "auto_scaling_policies" : [ {
    "node_group_name" : "task_node_analysis_group",
    "resource_pool_name" : "default",
    "auto_scaling_policy" : {
      "auto_scaling_enable" : true,
      "min_capacity" : 0,
      "max_capacity" : 1,
      "resources_plans" : [ {
        "period_type" : "daily",
        "effective_days" : [ "SUNDAY" ],
        "start_time" : "12:00",
        "end_time" : "13:00",
        "min_capacity" : 2,
        "max_capacity" : 3
      } ],
      "rules" : [ {
        "name" : "default-expand-1",
        "description" : "",
        "adjustment_type" : "scale_out",
        "cool_down_minutes" : 5,
        "scaling_adjustment" : 1,
        "trigger" : {
          "metric_name" : "YARNAppRunning",
          "metric_value" : 100,
          "comparison_operator" : "GTOE",
          "evaluation_periods" : 1
        }
      } ]
    }
  } ]
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.