查看策略列表
功能介绍
该接口用于查询指定项目下所有策略的详细信息。
URI
GET /v1/{project_id}/pe/policy
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token。 |
|
Content-Type |
是 |
String |
指定类型为application/json。 枚举值:
|
|
resourcetype |
是 |
String |
资源类型,nod或者app。 枚举值:
|
|
Cluster-Id |
是 |
String |
集群ID。 |
响应参数
状态码: 200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
errorCode |
String |
错误码 |
|
errorMessage |
String |
详细信息 |
|
policies |
Array of AllPolicyContext objects |
修改后的策略详细信息 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
id |
String |
策略ID。 |
|
group_id |
String |
策略组ID。 |
|
name |
String |
策略名称。 |
|
policy_type |
String |
策略类型。 |
|
rule |
AllRule object |
触发策略的规则。 |
|
create_time |
String |
创建时间。 |
|
update_time |
String |
更新时间。 |
|
status |
String |
状态。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
conditions |
Array of AllConditions objects |
匹配条件具体内容。如果是告警策略,则多个策略的condition条件不能有重合,如:同一指标不能既大于10%,又小于20% |
|
actions |
Array of Action objects |
指定策略匹配成功后执行的动作。 |
|
name |
String |
策略名称。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
launch_time |
String |
策略触发时间。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
recurrence_type |
String |
周期类型,定时策略此字段为空。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
recurrence_value |
String |
周期触发时间, 定时策略此字段为空。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
start_time |
Integer |
周期策略的起始时间, 定时策略此字段为空。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
end_time |
Integer |
周期策略的结束时间, 定时策略此字段为空。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
time_zone |
String |
时区。 当policy_type为SCHEDULED或RECURRENCE时,存在此字段。 |
|
metric_namespace |
String |
指标命名空间。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
metric_name |
String |
指标名称。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
metric_unit |
String |
单位 说明 随指标名称变化而变化,具体信息从AMS接口获取。 当policy_type为ALARM时,存在此字段。 |
|
period |
Integer |
统计周期,单位:秒。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
evaluation_periods |
Integer |
连续周期数。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
statistic |
String |
统计方式。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
metric_operation |
String |
指标操作符 包含“>”、“<”。 例如,“>”表示当metric大于metric_thresholdUpdate值时触发actions。 当policy_type为ALARM时,存在此字段。 枚举值:
|
|
metric_threshold |
Integer |
阈值条件。 当policy_type为ALARM时,存在此字段。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
type |
String |
枚举值:
|
|
parameters |
Array of Parameter objects |
包含扩缩容的实例数。 |
请求示例
无
响应示例
状态码: 200
OK
请求执行完成。
{
"errorCode" : "SVCSTG.PE.0",
"errorMessage" : "",
"policies" : [ {
"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" : ">",
"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"
}, {
"id" : "9aafbd3d-eac4-4a92-a342-5b6f8d60fff2",
"name" : "dingshi2",
"group_id" : "77c37e1f-aa0c-438d-8445-39b3997786a2",
"policy_type" : "SCHEDULED",
"rule" : {
"name" : "",
"conditions" : [ {
"launch_time" : "2017-12-22T06:30Z",
"recurrence_type" : "",
"recurrence_value" : "",
"start_time" : "",
"end_time" : ""
} ],
"actions" : [ {
"type" : "scale_set_k8s",
"parameters" : {
"scale_unit" : 1
}
} ]
},
"create_time" : "2017-12-21T09:14:00Z",
"update_time" : "2017-12-21T09:14:00Z",
"status" : "enabled"
} ]
}
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
OK 请求执行完成。 |
|
400 |
BadRequest 非法请求。建议直接修改该请求,不要重试该请求。 |
|
401 |
Unauthorized 在客户端提供认证信息后,返回该状态码,表明服务端指出客户端所提供的认证信息不正确或非法。 |
|
403 |
Forbidden 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。 |
|
500 |
InternalServerError 表明服务端能被请求访问到,但是不能理解用户的请求。 |
|
503 |
ServiceUnavailable 被请求的服务无效。建议直接修改该请求,不要重试该请求。 |
错误码
请参见错误码。