报警模版导入
更新时间:2026-06-26
报警模板导入
批量导入报警模板,该接口支持覆盖已存在的同名模板。
API Explorer
去调试
您可以在 API Explorer 中直接运行该接口,免去您计算签名的困扰。运行成功后,API Explorer 可以自动生成 SDK 代码示例。
Plain Text
1POST /v3/bcm?action=ImportAlarmTemplates HTTP/1.1
2Host: bcm.bj.baidubce.com
3Authorization: authorization string
4
5{
6 "overwrite": true,
7 "templates": [{"scope": "BCE_BCC", "resourceType": "Instance", "subResourceType": "", "name": "bcc_temp_1", "comment": "test", "rules": [...]}]
8}
请求头域
除公共头域外,无其他特殊头域
请求参数
| 参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号,当前取值为v3 |
| overwrite | Boolean | 是 | RequestBody参数 | 若模板重名,是否覆盖(true覆盖/false跳过) |
| templates | List<Template> | 是 | RequestBody参数 | 报警模板列表 |
返回状态码
成功返回200,失败返回见错误码
返回头域
除公共头域外,无其他特殊头域
返回参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| success | Boolean | 请求是否成功 |
| code | String | 响应码,内容错误时为InvalidParameter |
| message | String | 错误信息 |
| errTemplates | List<ErrTemplate> | 内容错误的模板列表 |
请求示例
Plain Text
1POST /v3/bcm?action=ImportAlarmTemplates HTTP/1.1
2HOST bcm.bj.baidubce.com
3Authorization bce-auth-v1/accessKeyId/2024-10-11T10:00:00Z/1800/host/signature
4
5{
6 "overwrite": true,
7 "templates": [{"scope": "BCE_BCC", "resourceType": "Instance", "subResourceType": "", "name": "bcc_temp_1", "comment": "test", "rules": [{"conditions": [{"metricName": "CpuIdlePercent", "metricDimensions": [], "operator": "<", "threshold": 100, "aggregateType": "AVG", "windowSeconds": 300, "displayUnit": "%", "displayThreshold": "100"}], "pendingCount": 1, "checkIntervalSeconds": 60}]}]
8}
响应示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 8a3b5c7d-1234-5678-abcd-ef0123456789
3Date: Fri, 11 Oct 2024 10:10:30 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Server: BWS
7
8{
9 "success": false,
10 "code": "InvalidParameter",
11 "message": "",
12 "errTemplates": [
13 {
14 "index": 3,
15 "template": {"scope": "BCE_BCC"},
16 "message": "name is required"
17 }
18 ]
19}
评价此篇文章
