查看Prometheus告警规则列表。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Name |
string |
否 |
告警规则名称。 |
Prometheus_Alert |
| RegionId |
string |
是 |
地域 ID。 |
cn-hangzhou |
| ClusterId |
string |
是 |
集群 ID。 |
c0bad479465464e1d8c1e641b0afb**** |
| Type |
string |
否 |
告警规则类型。 |
自定义 |
| Status |
integer |
否 |
告警规则启用状态,取值:
|
1 |
| MatchExpressions |
string |
否 |
标签匹配条件的 JSON 串。关于此字段的详细说明参见下文关于参数 MatchExpressions 的补充说明。 |
[{"key":"severity","value":"critical","operator":"re"}] |
| Tags |
array<object> |
否 |
标签。 |
|
|
object |
否 |
标签。 |
||
| Key |
string |
否 |
标签的键(key)。 |
owner |
| Value |
string |
否 |
标签的值(value)。 |
zhangsan |
关于参数 MatchExpressions 的补充说明
JSON 串示例及说明
[
{
"key":"severity", // 标签的 Key。
"value":"critical", // 标签的 Value。
"operator":"re" // eq:等于;re:匹配正则。
}
]
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| RequestId |
string |
请求 ID。 |
9FEA6D00-317F-45E3-9004-7FB8B0B7**** |
| PrometheusAlertRules |
array<object> |
返回结构体。 |
|
|
array<object> |
返回结构体。 |
||
| Status |
integer |
告警规则启用状态,取值:
|
1 |
| Type |
string |
告警规则类型。 |
自定义 |
| NotifyType |
string |
通知类型, 取值:
|
ALERT_MANAGER |
| Expression |
string |
告警表达式。 |
100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \"pod_name\", \"$1\", \"pod\", \"(.*)\")) by (pod_name))>75 |
| Message |
string |
告警通知消息,支持按照{{$labels.xxx}}格式来引用标签。 |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Duration |
string |
持续时间,范围在 1m~1440m,单位为分钟。 |
1m |
| DispatchRuleId |
integer |
通知策略 ID,当 NotifyType 指定为 |
10282 |
| AlertName |
string |
告警规则名称。 |
Prometheus_Alert |
| AlertId |
integer |
告警规则 ID。 |
3888704 |
| ClusterId |
string |
集群 ID。 |
c0bad479465464e1d8c1e641b0afb**** |
| Labels |
array<object> |
告警规则的标签。 |
|
|
object |
告警规则的标签。 |
||
| Name |
string |
标签的名称。 |
severity |
| Value |
string |
标签的值。 |
critical |
| Annotations |
array<object> |
告警规则的注释。 |
|
|
object |
告警规则的注释。 |
||
| Name |
string |
注释的名称。 |
message |
| Value |
string |
注释的值。 |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Tags |
array<object> |
标签。 |
|
|
object |
标签。 |
||
| Key |
string |
Tag 的主键。 |
key |
| Value |
string |
Tag 的值。 |
value |
| Code |
integer |
状态码。200 为成功,其他状态码为异常。 |
200 |
| Message |
string |
返回结果的提示信息。 |
success |
| Success |
boolean |
调用是否成功。 |
True |
示例
正常返回示例
JSON格式
{
"RequestId": "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
"PrometheusAlertRules": [
{
"Status": 1,
"Type": "自定义",
"NotifyType": "ALERT_MANAGER",
"Expression": "100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \\\"pod_name\\\", \\\"$1\\\", \\\"pod\\\", \\\"(.*)\\\")) by (pod_name))>75",
"Message": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%",
"Duration": "1m",
"DispatchRuleId": 10282,
"AlertName": "Prometheus_Alert",
"AlertId": 3888704,
"ClusterId": "c0bad479465464e1d8c1e641b0afb****",
"Labels": [
{
"Name": "severity",
"Value": "critical"
}
],
"Annotations": [
{
"Name": "message",
"Value": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%"
}
],
"Tags": [
{
"Key": "key",
"Value": "value"
}
]
}
],
"Code": 200,
"Message": "success",
"Success": true
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。