Updated on 2023-06-28 GMT+08:00

Querying a Policy

Function

This API is used to query details about a policy of a specified project.

URI

GET /v1/{project_id}/pe/policy/{policy_id}

Table 1 describes the parameters.

Table 1 Parameters

Parameter

Mandatory

Description

project_id

Yes

Project ID.

policy_id

Yes

Policy ID.

Request

Request headers

None

Request parameters

None

Example request

None

Response

Response parameters

Table 2 describes the response parameters.

Table 2 Response parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error details.

policy

See Table 3.

Details about a modified policy.

Table 3 policy parameters

Parameter

Type

Description

id

String

Policy ID.

name

String

Policy name.

policy_type

String

Policy type.

rule

See Table 4.

Policy trigger rule.

create_time

String

Creation time.

update_time

String

Update time.

status

String

Status.

Table 4 rule parameters

Parameter

Type

Description

name

String

Policy name.

conditions

See Table 5.

Condition contents.

actions

See Table 6.

Action executed after a specified policy is successfully matched.

Table 5 conditions parameters

Parameter

Type

Description

metric_namespace

String

Namespace.

metric_name

String

Metric name.

metric_unit

String

Unit.

period

Integer

Statistical period (unit: s).

evaluation_periods

Integer

Number of consecutive periods.

statistic

String

Statistic.

metric_operation

String

Metric operator.

metric_threshold

Float

Threshold criterion.

Table 6 actions parameters

Parameter

Type

Description

type

String

Scale-in or -out. The value containing k8s indicates a container application and that containing vm indicates a process application.

parameters

See Table 7.

Number of scale-in or -out instances.

Table 7 parameters

Parameter

Type

Description

scale_unit

Integer

Number of scale-in or -out instances.

Example response

{
    "errorCode" : "SVCSTG.PE.0",
    "errorMessage" : "",
    "policy" : {
        "id" : "8accffb6-e0ed-4433-b216-ccf6960eb1ad",
        "name" : "alarm",
        "group_id" : "77c37e1f-aa0c-438d-8445-39b3997786a2",
        "policy_type" : "ALARM",
        "rule" : {
            "name" : "",
            "conditions" : [{
                    "metric_namespace" : "PAAS.CONTAINER",
                    "metric_name" : "cpuCoreLimit",
                    "metric_unit" : "Percent",
                    "period" : 60,
                    "evaluation_periods" : 1,
                    "statistic" : "average",
                    "metric_operation" : "\u003e",
                    "metric_threshold" : 100,
                    "metric_dimensions" : null
                }
            ],
            "actions" : [{
                    "type" : "scale_out_k8s",
                    "parameters" : {
                        "scale_unit" : 1
                    }
                }
            ]
        },
        "create_time" : "2017-12-21T09:13:42Z",
        "update_time" : "2017-12-21T09:13:42Z",
        "status" : "enabled"
    }
}

Error Code

Table 8 Error codes

Error Code

Message

Solution

SVCSTG.PE.4031012

Failed to verify the project ID.

Check whether the parameter meets requirements.

SVCSTG.PE.5001203

Query error.

Contact technical support.