DescribeAlarmPolicy
Updated at:2025-11-03
Description
Get alarm policy details
Request
- Request syntax
Text
1GET /v1/alarm/policy?name=${PolicyName} HTTP/1.1
2Host: <Endpoint>
3Authorization: <Authorization String>
4Content-Type: application/json; charset=utf-8
- Request headers
No additional headers are required beyond the standard request headers.
- Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| PolicyName | String | Yes | Path | Alarm strategy name |
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 |
| policy | Policy | Alarm policy details |
The element structure of Policy object is as follows:
| Field | Types | Description |
|---|---|---|
| id | String | Alarm policy ID, unique |
| name | String | Alarm policy name, unique |
| objects | List<LogStore> | List of monitor objects. Fill in this field when all logstores share the target logstore. |
| targets | List<Target> | List of execution statements |
| triggerConditions | List<TriggerCondition> | List of trigger conditions |
| groups | List<String> | Group trigger |
| schedule | Schedule | Execution cycle |
| pendingCount | Int | Continuous trigger threshold, number of consecutive times the threshold is triggered before an alarm is raised |
| repeatIntervalMinute | Int | Repeat alarm interval, unit: minutes, default value: 0, which means repeat alarm is disabled |
| recoverWithoutNotice | Bool | Whether to notify after recovery, true: no notification, false: notification, defaulting to false |
| state | String | Policy activation status. ENABLED: Enabled; DISABLED: Disabled |
| noticeState | String | Notification activation status, ENABLED: Enabled; DISABLED: Disabled |
| notices | List<Notice> | Alarm notification template, reference: BCM Notification Template API |
| noticeRawLogs | List<NoticeRawLog> | Whether to include original logs in alarm notifications |
Each LogStore element structure in the objects array is as follows:
| Field | Types | Description |
|---|---|---|
| project | String | Logstore project, defaulting to "default" |
| logStoreName | String | Logstore name |
The element structure of each target in targets array is as follows:
| Parameter name | Types | Description |
|---|---|---|
| query | String | Execution statement |
| startTimeOffsetMinute | Int | Query start time offset, value range: [-1440, 0) |
| endTimeOffsetMinute | Int | Value range: (startTimeOffsetMinute, 0] |
| object | LogStore | 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 | Description |
|---|---|---|
| level | String | Alarm level, required. Options: INFO, WARN, and CRITICAL |
| condition | String | Trigger condition expression |
Schedule element structure is as follows:
| Parameter name | Types | Description |
|---|---|---|
| intervalMinute | Int | Fixed interval, unit: minutes, value range [1, 1440] |
| fixTimeMinute | Int | Specified time, minutes of the day, value range [0, 1440) |
| dayOfWeek | Int | Fixed time frequency; 0: Daily. 1~7 represents Monday to Sunday in a week |
Notice element structure is as follows:
| Parameter name | Types | Description |
|---|---|---|
| id | String | BCM alarm template ID |
The element structure of NoticeRawLog is as follows:
| Parameter name | Types | Description |
|---|---|---|
| type | String | Configuration type, REF: Associated execution statement, CUSTOM: Custom search statement |
| refTarget | String | If type=REF, it represents the referenced execution statement sequence number, counting from 0 |
| customTarget | Target | If type=CUSTOM, fill in the custom execution statement |
| columns | List<String> | List of field names displayed in the original logs. If not filled, all fields will be displayed |
| limit | Int | Number of logs displayed, maximum: 5 |
Error code
Apart from standard error codes, the following codes may be returned:
| Error code | Error message | Description | HTTP status code |
|---|---|---|---|
| AlarmPolicyNotFound | AlarmPolicy not found | Alarm policy does not exist | 404 |
Example
- Request example
Text
1GET /v1/alarm/policy?name=policy-name 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
- 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", // Error code
8 "message": "", // Error details
9 "policy": {
10 // Alarm policy name, unique under the same user
11 "name": "policy-name",
12
13 // Policy ID, unique under the same user
14 "id": "p-nRyKJOpr",
15
16 // policy enabled status, options:
17 // ENABLED - enabled
18 // DISABLED - disabled
19 "state": "ENABLED",
20
21 // Notification enabled status, options:
22 // ENABLED - enabled
23 // DISABLED - disabled
24 "noticeState": "ENABLED",
25
26 // Notification enabled status, options
27 // ENABLED - enabled
28 // DISABLED - disabled
29 "noticeState": "ENABLED",
30
31 "createdTime": "20240410T10:12:30Z", // Creation time, UTC time
32 "updatedTime": "20240410T10:12:30Z", // Update time, UTC time
33
34 // List of monitor objects. When all logstores share the target logstore, this field is populated
35 "objects": [
36 {
37 "logStoreName": "test-logstore-52" // Logstore name
38 },
39 ],
40
41 // List of execution statements
42 "targets": [
43 {
44 // Execution statement
45 "query": "select sum(age) as age",
46 // Query start time offset, required, value range: [-1440, 0)
47 "startTimeOffsetMinute": -1440,
48 // Query end time offset, required, value range: (startTimeOffsetMinute, 0]
49 "endTimeOffsetMinute": 0,
50
51 // Target logstore. When each execution statement specifies a logstore separately, this field is filled in
52 "object": {
53 "logStoreName": "test-logstore-52" // Logstore name
54 }
55 }
56 ],
57
58 // List of trigger conditions
59 "triggerConditions": [
60 {
61 // Alarm level, options:
62 // INFO - Notification,
63 // WARN - Warning
64 // CRITICAL - Critical
65 "level": "WARN",
66
67 // Trigger condition expression
68 "condition": "$1.age > 1"
69 }
70 ],
71
72 // Group trigger
73 "groups": ["$1.age", "$1.salary"],
74
75 // Execution cycle. Either fixed interval or specified time must be set, but not both
76 "schedule": {
77 // Fixed interval, unit: minutes, value range [1, 1440]
78 "intervalMinute": 1,
79
80 // Specified time, minutes of the day, value range [0, 1440)
81 "fixTimeMinute": 120, // In the example, 120 represents the 120th minute of the day, i.e., 2:00 AM
82
83 // Fixed time frequency; 0: Daily 1~7 represents Monday to Sunday in a week
84 "dayOfWeek": 3,
85 },
86
87 // Continuous trigger threshold, number of consecutive times the threshold is triggered before an alarm is raised
88 "pendingCount": 1,
89
90 // Repeat alarm interval, unit: minutes, default value: 0, which means repeat alarm is disabled
91 "repeatIntervalMinute": 5,
92
93 // Whether to notify after recovery, true: notify, false: do not notify, default
94 "recoverAlarmNotice": true,
95
96 // Alarm notification template list
97 "notices": [
98 {
99 // BCM alarm template ID
100 "id": "testNotice"
101 }
102 ],
103
104 // Whether to include the original log in the alarm content, false: do not include, default true: include
105 "noticeWithRawLog" : true,
106
107 // Alarm notification content configuration
108 "noticeRawConfigs" : [
109 {
110 // Configuration type, required
111 // REF Automatically associate execution statements
112 // CUSTOM Custom search statement
113 "type" : "CUSTOM",
114
115 // If type is REF, it represents the execution statement sequence number
116 "refTarget" : 1,
117
118 // If type is AUTO_ASSOCIATED, it represents a custom search statement
119 "query" : "match *",
120
121 // If each execution statement selects a logstore separately and is configured as a custom search statement, this represents the logstore
122 "object" : {
123 // Logstore project, required
124 "project" : "default",
125 // Logstore name, required
126 "logStoreName" : "bls-ng-log"
127 },
128 // Display fields, required
129 // All - All fields
130 // SpecifiedFields - Specified fields
131 "displayType" : "ALL",
132
133 // Specified field name list, optional
134 "display_fields" : ["requestid", "status"],
135 // Number of logs to display, maximum value is 5
136 "limit" : 4,
137 }
138 ]
139 }
140}
