更新时间:2025-09-18 GMT+08:00

创建告警订阅

功能介绍

创建告警订阅。

调用方法

请参见如何调用API

URI

POST /v2/{project_id}/alarm-subs

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

项目ID。获取方法请参见获取项目ID

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

请求参数

表2 请求Body参数

参数

是否必选

参数类型

描述

name

String

参数解释

告警订阅名称。

取值范围

不涉及。

enable

Integer

参数解释

是否开启订阅。

取值范围

不涉及。

alarm_level

String

参数解释

告警级别。

取值范围

不涉及。

notification_target

String

参数解释

消息主题地址。

取值范围

不涉及。

notification_target_name

String

参数解释

消息主题名称。

取值范围

不涉及。

notification_target_type

String

参数解释

消息主题类型,支持SMN。

取值范围

不涉及。

time_zone

String

参数解释

时区。

取值范围

不涉及。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

id

String

参数解释

告警订阅ID。

取值范围

不涉及。

name

String

参数解释

告警订阅名称。

取值范围

不涉及。

enable

Integer

参数解释

是否开启订阅。

取值范围

不涉及。

alarm_level

String

参数解释

告警级别。

取值范围

不涉及。

project_id

String

参数解释

项目ID。

取值范围

不涉及。

name_space

String

参数解释

所属服务。

取值范围

不涉及。

notification_target

String

参数解释

消息主题地址。

取值范围

不涉及。

notification_target_name

String

参数解释

消息主题名称。

取值范围

不涉及。

notification_target_type

String

参数解释

消息主题类型。

取值范围

不涉及。

language

String

参数解释

语言。

取值范围

不涉及。

time_zone

String

参数解释

时区。

取值范围

不涉及。

请求示例

开启名为“zrf-test-12”的紧急、重要、次要告警订阅,并选择地址为“urn:smn:cn-north-7:4cf650fd46704908aa071b4df2453e1e:dws-test-nodelete”的SMN消息主题“dws-test-nodelete”。

https://{Endpoint}/v2/4cf650fd46704908aa071b4df2453e1e/alarm-subs

{
  "alarm_level" : "urgent,important,minor",
  "enable" : 1,
  "name" : "zrf-test-12",
  "notification_target" : "urn:smn:cn-north-7:4cf650fd46704908aa071b4df2453e1e:dws-test-nodelete",
  "notification_target_name" : "dws-test-nodelete",
  "notification_target_type" : "SMN",
  "time_zone" : "GMT+08:00"
}

响应示例

状态码:200

创建告警订阅成功。

{
  "id" : "273ce506-dad8-411c-92f9-be5004739b40",
  "name" : "zrf-test-12",
  "enable" : 1,
  "language" : "zh-cn",
  "alarm_level" : "urgent,important,minor",
  "project_id" : "4cf650fd46704908aa071b4df2453e1e",
  "name_space" : "dws",
  "notification_target" : "urn:smn:cn-north-7:4cf650fd46704908aa071b4df2453e1e:dws-test-nodelete",
  "notification_target_name" : "dws-test-nodelete",
  "notification_target_type" : "SMN",
  "time_zone" : "GMT+08:00"
}

状态码

状态码

描述

200

创建告警订阅成功。

400

请求错误。

401

鉴权失败。

403

没有操作权限。

404

找不到资源。

500

服务内部错误。

503

服务不可用。