Viewing Auto Scaling Policies - ShowAutoScalingPolicy
Function
This API is used to view all autoscaling policy information of a specified cluster, including autoscaling rules, trigger conditions, and current status.
Constraints
None
Debugging
You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and supports sample SDK code debugging.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
URI
GET /v2/{project_id}/autoscaling-policy/{cluster_id}
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Constraints N/A Range The value must consist of 1 to 64 characters. Only letters and digits are allowed. Default Value N/A |
| cluster_id | Yes | String | Definition Cluster ID. For details about how to obtain the cluster ID, see Obtaining a Cluster ID. Constraints N/A 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
| Parameter | Type | Description |
|---|---|---|
| [Array element] | Array of AutoScalingPolicyV2 objects | Definition The auto scaling policy list. For details, see Table 3. Constraints N/A |
| Parameter | Type | Description |
|---|---|---|
| node_group_name | String | Definition Node group name. Constraints Only letters, digits, and underscores (_) are allowed. Except for the default system node groups, custom node group names must contain 3 to 14 characters. |
| resource_pool_name | String | Definition Pool name. Constraints The value can contain 1 to 50 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. |
| auto_scaling_policy | AutoScalingPolicyInfo object | Definition The auto scaling policy. For details, see Table 4. Constraints N/A |
| Parameter | Type | Description |
|---|---|---|
| auto_scaling_enable | Boolean | Definition Whether to enable the auto scaling policy. Range
|
| min_capacity | Integer | Definition Minimum number of nodes left in the node group. Range 0-500 |
| max_capacity | Integer | Definition Maximum number of nodes in the node group. Range 0-500 |
| resources_plans | Array of ResourcesPlan objects | Definition Resource plan list. If this parameter is left blank, the resource plan is disabled. When auto_scaling_enable is set to true, either this parameter or rules must be configured. For details about this parameter, see Table 5. Range N/A |
| rules | Array of Rule objects | Definition Auto scaling rules. When auto scaling is enabled, either a resource plan or an auto scaling rule must be configured. A maximum of five autoscaling rules are allowed. For details, see Table 6. Range N/A |
| tags | Array of Tag objects | Definition Auto scaling tags. For details, see Table 8. A maximum of 20 tags are allowed. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| period_type | String | Definition Cycle type of a resource plan. This parameter can be set to daily only. Range daily: Charges are calculated by day. |
| start_time | String | Definition 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. Range 00:00–23:59 |
| end_time | String | Definition End time of a resource plan. The format is the same as that of start_time. The value cannot be earlier than the start_time, and the interval between start_time and start_time cannot be less than 30 minutes. Range N/A |
| min_capacity | Integer | Definition Minimum number of the preserved nodes in a node group in a resource plan. Range 0-500 |
| max_capacity | Integer | Definition Maximum number of the preserved nodes in a node group in a resource plan. Range 0-500 |
| effective_days | Array of strings | Definition 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 Range N/A |
| Parameter | Type | Description |
|---|---|---|
| name | String | Definition Name of an auto scaling rule. 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. |
| description | String | Definition Description about an auto scaling rule. Range The value can contain 0 to 1024 characters. |
| adjustment_type | String | Definition Adjustment type of an auto scaling rule. Range
|
| cool_down_minutes | Integer | Definition Cluster cooling time after an auto scaling rule is triggered, when no auto scaling operation is performed. The unit is minute. Range The value ranges from 0 to 10080. 10080 indicates the number of minutes in a week. |
| scaling_adjustment | Integer | Definition Number of nodes that can be adjusted once. Range 1-100 |
| trigger | Trigger object | Definition The condition for triggering a rule. For details, see Table 7. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| metric_name | String | Definition Metric name. This triggering condition makes a judgment according to the value of the metric. Range For details about the value range, see Auto scaling metrics. |
| metric_value | String | Definition Metric threshold to trigger a rule. The value must be an integer or a number with two decimal places. Range Only integers or numbers with two decimal places are allowed. |
| comparison_operator | String | Definition Metric judgment logic operator. Range
|
| evaluation_periods | Integer | Definition Number of consecutive five-minute periods, during which a metric threshold is reached Range 1-288 |
| Parameter | Type | Description |
|---|---|---|
| key | String | Definition Tag key. Range
|
| value | String | Definition Tag value. Range
|
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition Error code. Range 400: The operation failed. |
| error_msg | String | Definition Error message. Range 400: The operation failed. |
Example Request
None
Example Response
Status code: 200
Auto scaling policies are displayed.
{
"auto_scaling_policies" : [ {
"node_group_name" : "task_node_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
}
} ]
}
} ]
} SDK Sample Code
The SDK sample code is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.mrs.v2.region.MrsRegion; import com.huaweicloud.sdk.mrs.v2.*; import com.huaweicloud.sdk.mrs.v2.model.*; public class ShowAutoScalingPolicySolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); ShowAutoScalingPolicyRequest request = new ShowAutoScalingPolicyRequest(); request.withClusterId("{cluster_id}"); try { ShowAutoScalingPolicyResponse response = client.showAutoScalingPolicy(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v2.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowAutoScalingPolicyRequest() request.cluster_id = "{cluster_id}" response = client.show_auto_scaling_policy(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := mrs.NewMrsClient(hcClient) request := &model.ShowAutoScalingPolicyRequest{} request.ClusterId = "{cluster_id}" response, err := client.ShowAutoScalingPolicy(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
See Status Codes.
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot