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

ListAlerts

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

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

获取告警列表。

请求说明

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

请求参数

参数名称类型是否必选示例值描述
ActionStringListAlerts公共参数,本接口值:ListAlerts。
VersionString2021-03-03公共参数,本接口值:2021-03-03。

Limit

Integer

10

告警单页数量:

  • 默认值 10。
  • 取值范围 0~100。
SearchAfterString*********翻页 token。
FilterObject AlertFilter-告警过滤条件。
OrderByStringInitialAlertTimestamp告警排序键,固定取值为InitialAlertTimestamp

Desc

Boolean

true

是否采用降序排序,取值:

  • true:采用降序排序。
  • false:不采用降序排序。

AlertFilter

参数名称类型是否必选示例值描述
IdsArray of String["173ee193-0aa6-4dd9-9074-9808c0f758cd"]按告警 ID 过滤,精确查询。

CurrentPhase

String

Active

按告警当前所处状态过滤,精确查询:

  • Pending:达到告警阈值但未满告警持续时间
  • Active:告警中
  • Resolved:自然解除
  • Disabled:人工解除
LevelStringP0按告警等级过滤,精确查询。包括:P0、P1 和 P2。
AlertingRuleIdsArray of String["90b5a3da-3464-4718-92e4-039bf41d3cff"]按告警规则 ID 过滤,精确查询。

请求示例

POST /?Action=ListAlerts&Version=2021-03-03
Content-Type:application/json
{
    "Limit": 10,
    "SearchAfter": "*********",
    "Filter": {
        "Ids": ["173ee193-0aa6-4dd9-9074-9808c0f758cd"],
        "CurrentPhase": "Active",
        "Level": "P0",
        "AlertingRuleIds": ["90b5a3da-3464-4718-92e4-039bf41d3cff"]
    },
    "OrderBy": "InitialAlertTimestamp",
    "Desc": true
}

返回参数

参数名称类型示例值描述
TotalInteger100告警总数。
ContinueTokenString*******用来分段 List 对象时填入的翻页 token。
ItemsArray of Alert-告警列表。

Alert

参数名称类型示例值描述
Idstring173ee193-0aa6-4dd9-9074-9808c0f758cd告警事件 ID。
AlertingRuleIdstring90b5a3da-3464-4718-92e4-039bf41d3cff告警规则 ID。
Levelsobject AlertingRuleLevel-告警等级类别。
InitialAlertTimestampstring2020-05-20T13:00:55Z告警开始时间,RFC3339 格式。
LastAlertTimestampstring2020-05-20T13:00:55Z告警最近触发时间,RFC3339 格式。
ResolveTimestampstring2020-05-20T13:00:55Z告警结束时间,RFC3339 格式。

CurrentPhase

string

Active

告警状态:

  • Pending:达到告警阈值但未满告警持续时间
  • Active:告警中
  • Resolved:自然解除
  • Disabled:人工解除
CurrentLevelstring-告警事件等级,包括:P0、P1 和 P2。
AlertingRuleTypestringvmp/PromQL告警规则类型,固定值为vmp/PromQL
AlertingRuleQueryobject AlertingRuleQuery-告警配置。
Resourceobject AlertResource-告警资源。

AlertingRuleLevel

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

For

String

5m

告警持续时间,取值:

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

Comparator

String

>

告警规则比较条件,取值:

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

AlertingRuleQuery

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

AlertResource

参数名称类型示例值描述

Labels

list LabelKeyValuePair

-

  • 资源标签列表。
  • 列表中每个值以 kv 结构组成。
  • key 值为资源标签(如 Pod)。
  • value 为资源名称(如 Pod Name)。

LabelKeyValuePair

参数名称类型示例值描述
KeyStringkey
ValueStringvalue

返回示例

HTTP/1.1 200 OK
Content-Type:application/json
{
    "ResponseMetadata": {
        "RequestId": "202211302208xxxx",
        "Action": "ListAlerts",
        "Version": "2021-03-03",
        "Service": "vmp",
        "Region": "cn-beijing"
    },
    "Result": {
        "Total": 100,
        "ContinueToken": "*******",
        "Items": [
            {
                "Id": "173ee193-0aa6-4dd9-9074-9808c0f758cd",
                "AlertingRuleId": "90b5a3da-3464-4718-92e4-039bf41d3cff",
                "Levels": [
                    {
                        "Level": " P0",
                        "For": " 5m",
                        "Comparator": " >",
                        "Threshold": 
                    }
                ],
                "InitialAlertTimestamp": "2020-01-01T00:00:00Z",
                "LastAlertTimestamp": "2020-01-01T00:00:00Z",
                "ResolveTimestamp": "2020-01-01T00:00:00Z",
                "CurrentPhase": "Active",
                "CurrentLevel": "P0",
                "AlertingRuleType": "vmp/PromQL",
                "AlertingRuleQuery": {
                    "WorkspaceId": " e28ae750-bbb8-4ff4-abf4-1e0e0f88808c",
                    "PromQL": " sum(up)"
                },
                "Resource": {
                    "Label": [
                        {
                            "Key": " key",
                            "Value": " value"
                        }
                    ],
                }
            }
        ]
    }
}

错误码

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

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 服务。