You need to enable JavaScript to run this app.
导航

ListAlertingRules

最近更新时间2024.04.19 11:53:55

首次发布时间2023.06.30 15:23:34

获取告警规则列表。

请求说明

  • 请求方式:POST
  • 请求地址:https://open.volcengineapi.com/?Action=ListAlertingRules&Version=2021-03-03

请求参数

参数名称类型是否必选示例值描述
ActionStringListAlertingRules公共参数,本接口值:ListAlertingRules。
VersionString2021-03-03公共参数,本接口值:2021-03-03。
PageNumberInteger1当前页数,最小值或默认值均为 1。

PageSize

Integer

10

单页数量:

  • 取值范围为 0~100。
  • 默认值为 10。
FilterObject AlertingRuleFilter-告警规则过滤条件。

AlertingRuleFilter

参数名称类型是否必选示例值描述
IdsArray of String["90b5a3da-3464-4718-92e4-039bf41d3cff"]按告警规则 ID 过滤,精确查询。
NameStringtest按告警规则名称过滤,模糊查询。
TypeStringvmp/PromQL按告警规则类型过滤,精确查询。
WorkspaceIdStringe28ae750-bbb8-4ff4-abf4-1e0e0f88808c按工作区 ID 过滤,精确查询。
NotifyPolicyIdsArray of String["8cd7b480-6387-44e5-aea4-db4ca2c4b47a"]按通知策略 ID 过滤,精确查询。
NotifyGroupPolicyIdsArray of String["ce4d942a-bac3-4ef6-b3a0-b7845b3b53bf"]按聚合策略 ID 过滤,精确查询。

Status

String

Running

按告警规则状态过滤:

  • Running:监控中
  • Disabled:已停用

请求示例

POST /?Action=ListAlertingRules&Version=2021-03-03
Content-Type:application/json
{
    "PageNumber": 1,
    "PageSize": 10,
    "Filter": {
        "Ids": ["90b5a3da-3464-4718-92e4-039bf41d3cff"],
        "Name": "test",
        "Type": "vmp/PromQL",
        "WorkspaceId": "e28ae750-bbb8-4ff4-abf4-1e0e0f88808c",
        "NotifyPolicyIds": ["8cd7b480-6387-44e5-aea4-db4ca2c4b47a"],
        "NotifyGroupPolicyIds": ["ce4d942a-bac3-4ef6-b3a0-b7845b3b53bf"],
        "Status": "Running"
    }
}

返回参数

参数名称类型示例值描述
TotalInteger100告警规则总数。
ItemsArray of AlertingRule-告警规则列表。

AlertingRule

参数名称类型示例值描述
IdString90b5a3da-3464-4718-92e4-039bf41d3cff告警规则 ID。
CreateTimeString2020-01-01T00:00:00Z告警规则创建时间。
UpdateTimeString2020-01-01T00:00:00Z告警规则更新时间。
NameStringmyRule告警规则名称。
DescriptionString这是一段描述告警规则描述信息。
TypeStringvmp/PromQL告警规则类型,固定取值为vmp/PromQL
QueryObject AlertingRuleQuery-告警配置。
LevelsArray of AlertingRuleLevel-告警等级。
NotifyPolicyIdString8cd7b480-6387-44e5-aea4-db4ca2c4b47a告警通知策略 ID。
NotifyGroupPolicyIdStringce4d942a-bac3-4ef6-b3a0-b7845b3b53bf告警聚合策略 ID。

Status

String

Running

告警规则状态:

  • Running:监控中
  • Disabled:已停用

AlertingRuleQuery

参数名称类型示例值描述
WorkspaceIdStringe28ae750-bbb8-4ff4-abf4-1e0e0f88808c工作区 ID。
PromQLStringsum(up)查询语句。

AlertingRuleLevel

参数名称类型示例值描述
LevelStringP0告警规则等级,包括:P0、P1 和 P2。

For

String

5m

告警持续时间:

  • 0s:立即触发
  • 1m:1分钟
  • 2m:2分钟
  • 5m:5分钟
  • 10m:10分钟

Comparator

String

>

告警规则比较条件:

  • > :大于
  • >= :大于等于
  • < :小于
  • <= :小于等于
  • == :等于
  • != :不等于
ThresholdFloat641.0告警规则阈值。

返回示例

HTTP/1.1 200 OK
Content-Type:application/json
{
    "ResponseMetadata": {
        "RequestId": "202211302208xxxx",
        "Action": "ListAlertingRules",
        "Version": "2021-03-03",
        "Service": "vmp",
        "Region": "cn-beijing"
    },
    "Result": {
        "Total": 100,
        "Items": [
            {
                "Id": "90b5a3da-3464-4718-92e4-039bf41d3cff",
                "CreateTime": "2020-01-01T00:00:00Z",
                "UpdateTime": "2020-01-01T00:00:00Z",
                "Name": "myRule",
                "Description": "这是一段描述",
                "Type": "vmp/PromQL",
                "Query": {
                    "WorkspaceId": " e28ae750-bbb8-4ff4-abf4-1e0e0f88808c",
                    "PromQL": " sum(up)"
                },
                "Levels": [
                    {
                        "Level": " P0",
                        "For": " 5m",
                        "Comparator": " >",
                        "Threshold": 
                    }
                ],
                "NotifyPolicyId": "8cd7b480-6387-44e5-aea4-db4ca2c4b47a",
                "NotifyGroupPolicyId": "ce4d942a-bac3-4ef6-b3a0-b7845b3b53bf",
                "Status": "Running"
            }
        ]
    }
}

错误码

本接口错误码如下表所示,公共错误码请参见 公共错误码

HTTP 状态码错误码错误信息描述
400InvalidParameter.{{parameter}}The specified {{parameter}} is invalid.参数不合法,请检查参数正确性后重试。
403ProductUnsubscribedYou are not subscribed to the Volcengine Managed Service for Prometheus (VMP). Please go to the VMP console web page to subscribe to the service当前账号未订阅 VMP 服务。