Call the CreateApplicationScalingRule operation to create an Auto Scaling rule for an application.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
edas:ManageApplication |
create |
*Cluster
|
None | None |
Request syntax
POST /pop/v1/eam/scale/application_scaling_rule HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| AppId |
string |
No |
The application ID. To get this ID, call the ListApplication operation. |
78194c76-3dca-418e-a263-cccd1ab4**** |
| ScalingRuleName |
string |
No |
The name of the Auto Scaling rule. The name must start with a lowercase letter. It can contain lowercase letters, digits, and hyphens (-). The name must be 1 to 32 characters long. |
cpu-trigger |
| ScalingRuleType |
string |
No |
The type of the Auto Scaling rule. Only the trigger type is supported. |
trigger |
| ScalingRuleEnable |
boolean |
No |
Specifies whether to enable the Auto Scaling rule.
|
true |
| ScalingRuleMetric |
string |
No |
This parameter is deprecated. |
1 |
| ScalingRuleTimer |
string |
No |
This parameter is deprecated. |
1 |
| ScalingRuleTrigger |
string |
No |
The trigger policy. Set this parameter to a JSON string of the ScalingRuleTriggerDTO object. For more information about the format, see Additional information about request parameters. |
ScalingRuleTriggerDTO{......} |
| ScalingBehaviour |
string |
No |
The configuration for custom scaling behaviors. For more information about the data structure, see the example. |
{ "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 instances. The value cannot exceed 1,000.
*/
Integer maxReplicas;
/**
* The minimum number of instances. The value cannot be less than 0.
*/
Integer minReplicas;
/**
* A 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 (scheduled) and app_metric (application monitoring).
*/
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 long.
*/
String name;
/**
The metadata of the trigger. This is a JSON map that contains string-to-string key-value pairs. The supported 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 interval. Valid values: daily, weekly, and monthly.
* dryRun: If this is set to false, the system monitors and performs scaling activities. If this is set to true, the system only monitors the metrics.
* timerInDay: The scaling cycle for each day. This parameter specifies when to start maintaining a specific number of replicas.
* timerInWeek: The day of the week in a cron expression. For example, Fri.
2. app_metric
{\"metricName\":\"arms_appstat.incall_QPS\",\"dryRun\":\"false\",\"targetValAvg\":\"true\",\"targetAverageValue\":\"100\"}
* metricName:
* arms_appstat.incall_QPS (queries per second (QPS))
* arms_appstat.incall_rt (response time)
* arms_appstat.system_CPU (CPU usage)
* arms_appstat.system_MEM (memory usage)
* dryRun: This parameter has the same meaning as the dryRun parameter for cron triggers.
* targetValAvg: Specifies whether to average the metric values. Set this to true for QPS and false for other metrics.
* targetAverageValue/targetValue: Use targetAverageValue if targetValAvg is true. Use targetValue if targetValAvg is false.
*/
String metadata;
}
}
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
integer |
The HTTP status code. |
200 |
| Message |
string |
The returned message. |
success |
| RequestId |
string |
The ID of the request. |
a5281053-08e4-47a5-b2ab-5c0323de7b5a |
| AppScalingRule |
object |
The Auto Scaling rule. |
|
| UpdateTime |
integer |
The UNIX timestamp when the Auto Scaling rule was updated. |
23212323123 |
| CreateTime |
integer |
The UNIX timestamp when the Auto Scaling rule was created. |
23212323123 |
| AppId |
string |
The ID of the application for the Auto Scaling rule. |
78194c76-3dca-418e-a263-cccd1ab4**** |
| LastDisableTime |
integer |
The UNIX timestamp when the Auto Scaling rule was last disabled. |
23212323123 |
| MaxReplicas |
integer |
This parameter is deprecated. |
1 |
| ScaleRuleEnabled |
boolean |
The state of the Auto Scaling rule.
|
true |
| ScaleRuleType |
string |
The type of the rule. Only trigger is supported. |
trigger |
| MinReplicas |
integer |
This parameter is deprecated. |
1 |
| ScaleRuleName |
string |
The name of the Auto Scaling rule. |
cpu |
| Metric |
object |
This parameter is deprecated. |
|
| MinReplicas |
integer |
This parameter is deprecated. |
1 |
| MaxReplicas |
integer |
This parameter is deprecated. |
1 |
| Metrics |
array<object> |
This parameter is deprecated. |
|
|
object |
|||
| MetricTargetAverageUtilization |
integer |
This parameter is deprecated. |
1 |
| MetricType |
string |
This parameter is deprecated. |
cpu |
| Trigger |
object |
The trigger configuration. |
|
| MinReplicas |
integer |
The minimum number of replicas. The value cannot be less than 0. |
2 |
| MaxReplicas |
integer |
The maximum number of replicas. The value cannot exceed 1,000. |
122 |
| Triggers |
array<object> |
A list of triggers. |
|
|
object |
A list of triggers. |
||
| Type |
string |
The type of the trigger. Valid values: cron and app_metric. |
cron |
| MetaData |
string |
The metadata of the trigger. |
{"dryRun":true} |
| Name |
string |
The name of the trigger. |
cpu |
| Behaviour |
object |
The scaling behavior. |
|
| ScaleUp |
object |
The configuration of the scale-out behavior. |
|
| StabilizationWindowSeconds |
integer |
The cooldown period for scale-out events. Unit: seconds. Valid values: 0 to 3600. Default value: 0. |
0 |
| SelectPolicy |
string |
The policy for the scale-out step size. Valid values: Max, Min, and Disable. |
Max |
| Policies |
array<object> |
The policy configuration. |
|
|
object |
The policy configuration. |
||
| PeriodSeconds |
integer |
The period in which the policy is checked for execution. Unit: seconds. Valid values: 0 to 1800. |
15 |
| Type |
string |
The type of the policy. Valid values: Pods and Percent. |
Pods |
| Value |
string |
The value for the scaling behavior policy. This must be an integer greater than 0. If the policy type is Pods, the value specifies the number of pods. If the policy type is Percent, the value specifies a percentage, which can exceed 100%. |
10 |
| ScaleDown |
object |
The configuration of the scale-in behavior. |
|
| StabilizationWindowSeconds |
integer |
The cooldown period for scale-in events. Unit: seconds. Valid values: 0 to 3600. Default value: 300. |
300 |
| SelectPolicy |
string |
The policy for the scale-in step size. Valid values: Max, Min, and Disable. |
Max |
| Policies |
array<object> |
The policy configuration. |
|
|
object |
The policy configuration. |
||
| PeriodSeconds |
integer |
The period in which the policy is checked for execution. Unit: seconds. Valid values: 0 to 1800. |
15 |
| Type |
string |
The type of the policy. Valid values: Pods and Percent. |
Pods |
| Value |
string |
The value for the scaling behavior policy. This must be an integer greater than 0. If the policy type is Pods, the value specifies the number of pods. If the policy type is Percent, the value specifies a percentage, which can exceed 100%. |
10 |
Examples
Success response
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
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.