Modifying a Policy
Function
This API is used to modify a policy. Alarm policies can be modified, but scheduled and periodic policies cannot.
URI
PUT /v1/{project_id}/pe/policy/{policy_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. |
policy_id |
Yes |
String |
Policy ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Content type, which is application/json;charset=utf-8. Enumeration values:
|
Cluster-Id |
Yes |
String |
Cluster ID. |
Namespace |
Yes |
String |
Namespace. |
Deployment-Name |
Yes |
String |
Application name. |
X-Auth-Token |
Yes |
String |
Project-level token obtained from IAM. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
Yes |
String |
Policy ID. |
name |
Yes |
String |
Policy name, which cannot be modified. The value must contain 1 to 64 characters starting with a letter. Only digits, letters, underscores (_), and hyphens (-) are allowed. |
policy_type |
Yes |
String |
Policy type. Currently, only ALARM policies are supported. Enumeration values:
|
rule |
Yes |
AlarmRule object |
Policy trigger rule. |
group_id |
Yes |
String |
Policy group ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
actions |
Yes |
Array of Action objects |
Action executed after a specified policy is matched. |
conditions |
Yes |
Array of AlarmConditions objects |
Condition contents. A rule can contain multiple conditions in AND relationships. One condition describes the matching method of one metric. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
scale_out_k8s and scale_out_vm indicate a scale-out. scale_in_k8s and scale_in_vm indicate a scale-in. Note: The value containing k8s indicates a scale-in or -out for containerized applications and that containing vm indicates a scale-in or -out for process applications. Enumeration values:
|
parameters |
Yes |
Array of Parameter objects |
Number of scale-in or -out instances. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
scale_unit |
Yes |
Integer |
Number of scale-in or -out instances. The value is between the minimum number of instances to the maximum number of instances in a policy group. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
metric_namespace |
Yes |
String |
Metric namespace. Enumeration values:
|
metric_name |
Yes |
String |
Metric name. Enumeration values:
|
metric_unit |
Yes |
String |
Unit. Note: The value is retrieved from an AMS API and varies with the metric name. |
period |
Yes |
Integer |
Statistical period (unit: s). Enumeration values:
|
evaluation_periods |
Yes |
Integer |
Number of consecutive periods. Enumeration values:
|
statistic |
Yes |
String |
Statistic. Enumeration values:
|
metric_operation |
Yes |
String |
Metric operator. Option: > or <. For example, you can use > in a threshold criterion (when the value of a metric is greater than metric_thresholdUpdate) to trigger actions. Enumeration values:
|
metric_threshold |
Yes |
Integer |
Threshold condition. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
errorCode |
String |
Error code. |
errorMessage |
String |
Details. |
context |
PePolicyContext object |
Details about a modified policy. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Policy ID. |
name |
String |
Policy name, which cannot be modified. The value must contain 1 to 64 characters starting with a letter. Only digits, letters, underscores (_), and hyphens (-) are allowed. |
policy_type |
String |
Policy type. Currently, only ALARM policies are supported. Enumeration values:
|
rule |
AlarmRule object |
Policy trigger rule. |
Parameter |
Type |
Description |
---|---|---|
actions |
Array of Action objects |
Action executed after a specified policy is matched. |
conditions |
Array of AlarmConditions objects |
Condition contents. A rule can contain multiple conditions in AND relationships. One condition describes the matching method of one metric. |
Parameter |
Type |
Description |
---|---|---|
type |
String |
scale_out_k8s and scale_out_vm indicate a scale-out. scale_in_k8s and scale_in_vm indicate a scale-in. Note: The value containing k8s indicates a scale-in or -out for containerized applications and that containing vm indicates a scale-in or -out for process applications. Enumeration values:
|
parameters |
Array of Parameter objects |
Number of scale-in or -out instances. |
Parameter |
Type |
Description |
---|---|---|
scale_unit |
Integer |
Number of scale-in or -out instances. The value is between the minimum number of instances to the maximum number of instances in a policy group. |
Parameter |
Type |
Description |
---|---|---|
metric_namespace |
String |
Metric namespace. Enumeration values:
|
metric_name |
String |
Metric name. Enumeration values:
|
metric_unit |
String |
Unit. Note: The value is retrieved from an AMS API and varies with the metric name. |
period |
Integer |
Statistical period (unit: s). Enumeration values:
|
evaluation_periods |
Integer |
Number of consecutive periods. Enumeration values:
|
statistic |
String |
Statistic. Enumeration values:
|
metric_operation |
String |
Metric operator. Option: > or <. For example, you can use > in a threshold criterion (when the value of a metric is greater than metric_thresholdUpdate) to trigger actions. Enumeration values:
|
metric_threshold |
Integer |
Threshold condition. |
Example Requests
Modify an alarm policy.
PUT https://{Endpoint}/v1/{project_id}/pe/policy/{policy_id} { "group_id" : "943eba0f-b10a-4066-6261-1857a53500ff", "id" : "5c2eecea-32ac-42c0-be30-f73b15d68429", "name" : "policy_1", "policy_type" : "ALARM", "rule" : { "conditions" : [ { "metric_namespace" : "PAAS.CONTAINER", "metric_name" : "cpuUsage", "metric_unit" : "Percent", "period" : 60, "evaluation_periods" : 1, "statistic" : "average", "metric_operation" : ">", "metric_threshold" : 70 } ], "actions" : [ { "type" : "scale_out_k8s", "parameters" : { "scale_unit" : 1 } } ] } }
Example Responses
Status code: 200
OK
The request is successful.
{ "errorCode" : "SVCSTG.PE.0", "errorMessage" : "", "context" : { "id" : "5c2eecea-32ac-42c0-be30-f73b15d68429", "name" : "policy_1", "policy_type" : "ALARM", "rule" : { "conditions" : [ { "metric_namespace" : "PAAS.CONTAINER", "metric_name" : "cpuUsage", "metric_unit" : "Percent", "period" : 60, "evaluation_periods" : 1, "statistic" : "average", "metric_operation" : ">", "metric_threshold" : 70 } ], "actions" : [ { "type" : "scale_out_k8s", "parameters" : { "scale_unit" : 1 } } ] } } }
Status Codes
Status Code |
Description |
---|---|
200 |
OK The request is successful. |
400 |
Bad Request Invalid request. The client should not repeat the request without modifications. |
401 |
Unauthorized The authorization information is incorrect or invalid. |
403 |
ForbiddenThe request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications. |
500 |
Internal Server Error The server is able to receive the request but unable to understand the request. |
503 |
Service Unavailable The requested service is invalid. The client should not repeat the request without modifications. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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