UpdateAlarmPolicy
Updated at:2025-11-03
Description
Update Alarm Strategy
Request
- Request syntax
Text
1PUT /v1/alarm/policy HTTP/1.1
2Host: <Endpoint>
3Authorization: <Authorization String>
4Content-Type: application/json; charset=utf-8
5{
6 "name": <name>,
7 "id": <id>,
8}
- Request headers
No additional headers are required beyond the standard request headers.
- Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| id | String | Yes | RequestBody | Alarm policy ID, unique |
| name | String | Yes | RequestBody | Alarm policy name, unique |
| objects | List<LogStore> | No | RequestBody | List of monitor objects. Fill in this field when all logstores share the target logstore. |
| targets | List<Target> | Yes | RequestBody | List of execution statements |
| triggerConditions | List<TriggerCondition> | Yes | RequestBody | List of trigger conditions |
| groups | List<String> | No | RequestBody | Group trigger |
| schedule | Schedule | Yes | RequestBody | Execution cycle |
| pendingCount | Int | Yes | RequestBody | Continuous trigger threshold, number of consecutive times the threshold is triggered before an alarm is raised |
| repeatIntervalMinute | Int | No | RequestBody | Repeat alarm interval, unit: minutes, default value: 0, which means repeat alarm is disabled |
| recoverWithoutNotice | Bool | No | RequestBody | Whether to notify after recovery, true: no notification, false: notification, defaulting to false |
| state | String | No | RequestBody | Policy activation status. ENABLED: Enabled; DISABLED: Disabled |
| noticeState | String | No | RequestBody | Notification activation status, ENABLED: Enabled; DISABLED: Disabled |
| notices | List<Notice> | Yes | RequestBody | Alarm notification template, reference: BCM Notification Template API |
| noticeRawLogs | List<NoticeRawLog> | No | RequestBody | Whether to include original logs in alarm notifications |
Each LogStore element structure in the objects array is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| project | String | No | Logstore project, defaulting to "default" |
| logStoreName | String | Yes | Logstore name |
The element structure of each target in targets array is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| query | String | Yes | Execution statement |
| startTimeOffsetMinute | Int | Yes | Query start time offset, value range: [-1440, 0) |
| endTimeOffsetMinute | Int | Yes | Value range: (startTimeOffsetMinute, 0] |
| object | LogStore | No | Fill in this field when each execution statement specifies a logstore individually |
Each TriggerCondition element structure in the triggerConditions array is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| level | String | Yes | Alarm level, required. Options: INFO, WARN, and CRITICAL |
| condition | String | Yes | Trigger condition expression |
Schedule element structure is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| intervalMinute | Int | No | Fixed interval, unit: minutes, value range [1, 1440] |
| fixTimeMinute | Int | No | Specified time, minutes of the day, value range [0, 1440) |
| dayOfWeek | Int | No | Fixed time frequency; 0: Daily. 1~7 represents Monday to Sunday in a week |
Notice element structure is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| id | String | Yes | BCM alarm template ID |
The element structure of NoticeRawLog is as follows:
| Parameter name | Types | Required or not | Description |
|---|---|---|---|
| type | String | Yes | Configuration type, REF: Associated execution statement, CUSTOM: Custom search statement |
| refTarget | String | No | If type=REF, it represents the referenced execution statement sequence number, counting from 0 |
| customTarget | Target | No | If type=CUSTOM, fill in the custom execution statement |
| columns | List<String> | No | List of field names displayed in the original logs. If not filled, all fields will be displayed |
| limit | Int | Yes | Number of logs displayed, maximum: 5 |
Response
- Response headers
No additional headers are required beyond the standard response headers.
- Response parameters
| Field | Types | Description |
|---|---|---|
| success | Boolean | Whether the request succeeded |
| code | String | Request code, OK for success, or a specific error code for failure |
| message | String | Empty for request success, or a specific error message for request failure |
Error code
Apart from standard error codes, the following codes may be returned:
| Error code | Error message | Description | HTTP status code |
|---|---|---|---|
| InvalidParameter | Request param invalid: [msg] | Invalid parameter exception | 400 |
Example
- Request example
Text
1PUT /v1/alarm/policy HTTP/1.1
2Host: bls-log.bj.baidubce.com
3Authorization:bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304
4Content-Type: application/json; charset=utf-8
5{
6 // Policy ID
7 "id": "p-nRyKJOpr",
8
9 // Alarm policy name, unique under the same user, required
10 "name": "policy-name",
11
12 // List of monitor objects, optional. When all logstores share the target logstore, fill in this field
13 "objects": [
14 {
15 "project": "default", // Logstore project, default
16 "logStoreName": "test-logstore-52" // Logstore name
17 },
18 ],
19
20 // List of execution statements, required
21 "targets": [
22 {
23 // Execution statement, required
24 "query": "select sum(age) as age",
25 // Query start time offset, required, value range: [-1440, 0)
26 "startTimeOffsetMinute": -1440,
27 // Query end time offset, required, value range: (startTimeOffsetMinute, 0]
28 "endTimeOffsetMinute": 0,
29
30 // Target logstore, optional. When each execution statement specifies a logstore separately, fill in this field
31 "object": {
32 "logStoreName": "test-logstore-52" // Logstore name
33 }
34 }
35 ],
36
37 // List of trigger conditions, required
38 "triggerConditions": [
39 {
40 // Alarm level, required, options:
41 // INFO - Notification,
42 // WARN - Warning
43 // CRITICAL - Critical
44 "level": "WARN",
45
46 // Trigger condition expression, required
47 "condition": "$1.age > 1"
48 }
49 ],
50
51 // Group trigger, optional
52 "groups": ["$1.age", "$1.salary"],
53
54 // Execution cycle, required. Either fixed interval or specified time must be set, but not both
55 "schedule": {
56 // Fixed interval, unit: minutes, value range [1, 1440]
57 "intervalMinute": 1,
58
59 // Specified time, minutes of the day, value range [0, 1440)
60 "fixTimeMinute": 120, // In the example, 120 represents the 120th minute of the day, i.e., 2:00 AM
61 // Fixed time frequency; 0: Daily 1~7 represents a specific day in a week
62 "dayOfWeek": 0
63 },
64
65 // Continuous trigger threshold, number of consecutive times the threshold is triggered before an alarm is raised, required
66 "pendingCount": 1,
67
68 // Repeat alarm interval, unit: minutes, default value: 0, which means repeat alarm is disabled
69 "repeatIntervalMinute": 5,
70
71 // Whether to notify after recovery, true: no notification, false: notification, default
72 "recoverWithoutNotice": true,
73
74 // Policy activation status, options:
75 // ENABLED - Enabled
76 // DISABLED - Disabled
77 "state": "ENABLED",
78
79 // Notification activation status, options:
80 // ENABLED - Enabled
81 // DISABLED - Disabled
82 "noticeState": "ENABLED",
83
84 // Alarm notification template list, required
85 "notices": [
86 {
87 // BCM alarm template ID, required
88 "id": "testNotice"
89 }
90 ],
91
92 // Whether to include original logs in alarm notifications, optional
93 "noticeRawLogs" : [
94 {
95 // Configuration type, required
96 // REF - Associated execution statement
97 // CUSTOM - Custom search statement
98 "type" : "CUSTOM",
99
100 // If type=REF, required, indicating the referenced execution statement sequence number, counting from 0
101 "refTarget" : 1,
102
103 // If type=CUSTOM, fill in the custom execution statement
104 "customTarget": {
105 // Execution statement, required
106 "query": "select sum(age) as age",
107 // Query start time offset, required, value range: [-1440, 0)
108 "startTimeOffsetMinute": -1440,
109 // Query end time offset, required, value range: (startTimeOffsetMinute, 0]
110 "endTimeOffsetMinute": 0,
111
112 // Target logstore, optional. When each execution statement specifies a logstore separately, fill in this field
113 "object": {
114 "logStoreName": "test-logstore-52" // Logstore name
115 }
116 }
117
118 // List of field names displayed in the original logs, optional. If not filled, all fields will be displayed.
119 "columns": ["requestid", "status"],
120
121 // Number of logs displayed, maximum: 5, required
122 "limit" : 4,
123 }
124 ]
125}
- Response example
Text
1HTTP/1.1 201
2Content-Type: application/json; charset=utf-8
3X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
4Date: Fri, 10 Apr 2020 04:42:37 GMT
5{
6 "success": true,
7 "code": "OK",
8 "message": ""
9}
