You need to enable JavaScript to run this app.
导航
CreateSilencePolicy
最近更新时间:2025.05.23 14:58:50首次发布时间:2024.08.16 17:03:02
我的收藏
有用
有用
无用
无用

创建告警静默策略。

请求说明

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

请求参数

参数类型是否必选示例值描述
ActionStringCreateSilencePolicy接口名称。当前 API 的名称为 CreateSilencePolicy
VersionString2021-03-03接口版本。当前 API 的版本为 2021-03-03

Name

String

alert-silence-demo

告警静默策略名称。

  • 字符串形式,取值范围为 1~128 字符。
  • 支持中文,字母,数字,下划线和中划线。不能以数字,下划线开头。
  • 相同地域内名称唯一。

Description

String

这是一段描述

告警静默策略的描述信息。

  • 字符串形式,取值范围为 1~128 字符。
  • 支持任意 utf-8 字符。
LabelMatchersArray of Array of LabelMatcher-使用告警中包含的 Label,匹配需要静默的告警事件。
TimeRangeMatchersArray of TimeRangeMatcher-告警静默时间。

LabelMatcher

参数类型是否必选示例值描述
LabelStringapp需要屏蔽的告警资源标签,支持内置变量__alerting_rule_id,表示告警规则 ID。
ValueStringtest需要屏蔽的告警资源值,支持正则表达式。
OperatorStringEqual匹配条件,取值:Equal、NotEqual、RegexpEqual 和 RegexpNotEqual,不填写时默认值为 Equal。

TimeRangeMatcher

参数类型是否必选示例值描述
DateString2006-01-02 15:04~2006-01-03 14:04告警静默的时间段。用于配置指定时间段内的告警静默。
LocationStringAsia/Shanghai时区。
PeriodicDateObject of PeriodicDate-告警静默的周期。用于配置周期生效的告警静默。

PeriodicDate

参数类型是否必选示例值描述
TimeString20:00~21:12时间周期。支持以英文逗号,分隔不同的时间段,如 20:00~21:12,22:00~23:12。最多可以配置 4 个时间段。
WeekdayString1,3,5周几,表示每周的固定时间。支持以英文逗号,分隔不同的时间段,如1,3,5表示周每周的周一、周三和周五。最多可以配置 7 个时间段。
DayOfMonthString2~3月份内的日期,表示每月的固定时间。支持以英文逗号,分隔不同的时间段,如2~3表示每月的 2 号和 3 号。最多可以填 10 个时间段。

请求示例

POST https://open.volcengineapi.com/?Action=CreateSilencePolicy&Version=2021-03-03
Content-Type: application/json
{
    "Name": "alert-silence-demo",
    "Description": "这是一段描述",
    "LabelMatchers": [
        [
            {
                "Label": "app",
                "Value": "test",
                "Operator": "Equal"
            }
        ]
    ],
    "TimeRangeMatchers": [
        {
            "Date": "2006-01-02 15:04~2006-01-03 14:04",
            "Location": "Asia/Shanghai",
            "PeriodicDate": {
                "Time": "20:00~21:12",
                "Weekday": "1,3,5",
                "DayOfMonth": "2~3"
            }
        }
    ]
}

返回参数

参数类型示例值描述
IdStringe28ae750-bbb8-4ff4-abf4-1e0e0f88808c告警静默策略 ID。

返回示例

HTTP/1.1: 200 OK
Content-Type: application/json
{
    "ResponseMetadata": {
        "RequestId": "20230604110420****100232280022D31",
        "Action": "CreateSilencePolicy",
        "Version": "2021-03-03",
        "Service": "vmp",
        "Region": "cn-north-1"
    },
    "Result": {
        "Id": "e28ae750-bbb8-4ff4-abf4-1e0e0f88808c"
    }
}

错误码

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

HTTP 状态码错误码错误信息说明
400InvalidParameter.{{parameter}}The specified parameter {{parameter}} is invalid.输入不合法,如工作区名称不合法等。
400MissingParameter.{{parameter}}The required parameter {{parameter}} is missing.缺少必要的参数。
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 服务。
409Conflict.NameThe specified name conflicts with existing {{resource}}.指定的名称与已有资源重复。