Creates an auto scaling policy for an application.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
edas:ReadCluster | Read |
|
| none |
Request syntax
POST /pop/v1/eam/scale/application_scaling_rule
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
AppId | string | Yes | The ID of the application. You can call the ListApplication operation to query the application ID. For more information, see ListApplicationlink . | 78194c76-3dca-418e-a263-cccd1ab4**** |
ScalingRuleName | string | No | The name of the auto scaling policy. The name must start with a lowercase letter, and can contain lowercase letters, digits, and hyphens (-). The name must be 1 to 32 characters in length. | cpu-trigger |
ScalingRuleType | string | No | The type of the auto scaling policy. Set the value to trigger. | trigger |
ScalingRuleEnable | boolean | No | Specifies whether to enable the auto scaling policy. Valid values:
| true |
ScalingRuleMetric | string | No | This parameter is deprecated. | 1 |
ScalingRuleTimer | string | No | This parameter is deprecated. | 1 |
ScalingRuleTrigger | string | No | The trigger policy for the auto scaling policy. Set the value in the JSON format by using the ScalingRuleTriggerDTO class. For more information, see Additional information about request parameters. | ScalingRuleTriggerDTO{......} |
ScalingBehaviour | string | No | Configure custom elastic behavior, refer to the example for specific data structure. | { "scaleUp": { "stabilizationWindowSeconds": "0", "selectPolicy": "Max", "policies": [ { "type": "Pods", "value": 5, "periodSeconds": 15 } ] }, "scaleDown": { "stabilizationWindowSeconds": "300", "selectPolicy": "Max", "policies": [ { "type": "Percent", "value": 200, "periodSeconds": 15 } ] } } |
Additional information about request parameters
public class ScalingRuleTriggerDTO {
/**
* The maximum number of replicas. The maximum value is 1000.
*/
Integer maxReplicas;
/**
* The minimum number of replicas. The minimum value is 0.
*/
Integer minReplicas;
/**
* The list of triggers. Multiple triggers are supported.
*/
List<Trigger> triggers;
@Data
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class Trigger {
/**
* The type of the trigger. Valid values: cron and app_metric.
*/
String type;
/**
* The name of the trigger. The name must start with a letter, and can contain digits, letters, hyphens (-), and underscores (_). The name can be up to 30 characters in length.
*/
String name;
/**
The metadata of the trigger. Set this parameter to a JSON string that consists of key-value pairs. The metadata varies based on the trigger type.
1. cron
{"period":"weekly","dryRun":"false","timerInDay":[{"atTime":"08:00","targetReplicas":2},{"atTime":"20:00","targetReplicas":1}],"timerInWeek":["Sat","Thu"]}
* period: the scaling cycle. Valid values: daily, weekly, and monthly.
* dryRun: Value false indicates observation and scaling. Value true indicates observation only.
* timerInDay: the daily scaling cycle, which specifies the number of replicas to be maintained from a specific point in time.
* timerInWeek: the day of the week in the CRON expression. Example: Fri.
2. app_metric
{\"metricName\":\"arms_appstat.incall_QPS\",\"dryRun\":\"false\",\"targetValAvg\":\"true\",\"targetAverageValue\":\"100\"}
* metricName: the name of the metric. Valid values:
* arms_appstat.incall_QPS: the queries per second (QPS).
* arms_appstat.incall_rt: the response time (RT).
* arms_appstat.system_CPU: the CPU utilization.
* arms_appstat.system_MEM: the memory usage.
* dryRun: Value false indicates observation and scaling. Value true indicates observation only.
* targetValAvg: Value true indicates that the target value is an average value. Value false indicates that the target value is not an average value. Set this parameter to true only for the arms_appstat.incall_QPS metric.
* targetAverageValue or targetValue: Specify the targetAverageValue parameter if the targetValAvg parameter is set to true. Specify the targetValue parameter if the targetValAvg parameter is set to false.
*/
String metadata;
}
}
Response parameters
Examples
Sample success responses
JSON
format
{
"Code": 200,
"Message": "success",
"RequestId": "a5281053-08e4-47a5-b2ab-5c0323de7b5a",
"AppScalingRule": {
"UpdateTime": 23212323123,
"CreateTime": 23212323123,
"AppId": "78194c76-3dca-418e-a263-cccd1ab4****",
"LastDisableTime": 23212323123,
"MaxReplicas": 1,
"ScaleRuleEnabled": true,
"ScaleRuleType": "trigger",
"MinReplicas": 1,
"ScaleRuleName": "cpu",
"Metric": {
"MinReplicas": 1,
"MaxReplicas": 1,
"Metrics": [
{
"MetricTargetAverageUtilization": 1,
"MetricType": "cpu"
}
]
},
"Trigger": {
"MinReplicas": 2,
"MaxReplicas": 122,
"Triggers": [
{
"Type": "cron",
"MetaData": "{\"dryRun\":true}",
"Name": "cpu"
}
]
},
"Behaviour": {
"ScaleUp": {
"StabilizationWindowSeconds": 0,
"SelectPolicy": "Max",
"Policies": [
{
"PeriodSeconds": 15,
"Type": "Pods",
"Value": "10"
}
]
},
"ScaleDown": {
"StabilizationWindowSeconds": 300,
"SelectPolicy": "Max",
"Policies": [
{
"PeriodSeconds": 15,
"Type": "Pods",
"Value": "10"
}
]
}
}
}
}
Error codes
For a list of error codes, visit the Service error codes.