CreateAlarmPolicy

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
All documents
menu
No results found, please re-enter

BLS

  • Function Release Records
  • Product Description
    • Usage restrictions
    • Product Introduction
  • Product pricing
  • Quick Start
    • Introduction
    • Install agent
    • Create LogStore
    • Create Transmission Task
    • Log Analysis and Alerting
    • Create Delivery Task
  • Operation guide
    • Baidu Intelligent Cloud Environment Preparation
    • Overview
    • Identity and access management
    • Logset Management
    • Agent
      • Install Agent on Host
      • Install Agent in K8s Environment
      • Agent Management
      • Agent Release Version
      • Set Agent Startup Parameters
    • Log Collection
      • Transmission Task Collection
        • Create Transmission Task
        • Manage Transmission Task
      • Uploading Logs Using Kafka Protocol
    • Query analysis
      • Log query
      • SQL Syntax
      • Search Syntax
    • Dashboard
      • Overview
      • Management Dashboard
      • Management Dashboard Charts
    • Alarm management
      • Alert Overview
      • Alarm strategy
        • Management alarm strategy
        • Trigger conditions
      • Alarm history
      • Alert execution statistics
      • Alarm notification
        • Alarm Notification Template
        • Alarm callback
    • Data processing
      • Log Delivery
        • Log Delivery Overview
        • Create Delivery Task
        • Manage Delivery Task
      • Scheduled SQL Analysis
        • Manage Scheduled SQL Analysis Task
        • Create Scheduled SQL Analysis Task
      • Real-Time Consumption
      • Data processing
        • Data processing
          • Overview of data processing functions
          • Process control function
          • Mapping enrichment functions
          • Event operation functions
          • Field operation functions
          • Field value extraction functions
    • Log Applications
      • Intelligent Diagnostics
  • Best Practices
    • Use Year-Over-Year and Month-Over-Month as Alert Trigger Conditions
    • BLS Integration with Kibana
    • Use BLS via Grafana
  • Development Guide
    • API Reference
      • API function release records
      • API Overview
      • Interface Overview
      • General Description
      • Service domain
      • Common error codes
      • Terminology
      • Project Related APIs
        • Create Project
        • Update Project
        • Describe Project
        • Delete Project
        • List Project
      • LogStore Related APIs
        • Create LogStore
        • Update LogStore
        • Delete LogStore
        • Describe LogStore
        • Batch Get LogStore
        • List LogStore
      • LogStream Related APIs
        • List LogStream
      • LogRecord Related APIs
        • Push log PushLogRecord
        • Obtain logrecord PullLogRecord
        • Search analysis log QueryLogRecord
        • Histogram API QueryLogHistogram
      • Fast Query FastQuery Related Interfaces
        • Create Fast Query CreateFastQuery
        • Update Fast Query UpdateFastQuery
        • Delete Fast Query DeleteFastQuery
        • Get Fast Query Details DescribeFastQuery
        • Get Fast Query List ListFastQuery
      • Index Related APIs
        • Create Index
        • Update Index
        • Delete Index
        • Describe Index
      • Log Shipper LogShipper Related Interfaces
        • Create Log Shipper
        • Update Log Shipper
        • Set Single Log Shipper Status
        • Delete Single Log Shipper
        • Bulk Delete Log Shipper
        • List Log Shipper Records
        • List Log Shipper
        • Bulk Set Log Shipper Status
        • Get Log Shipper
      • Alarm-Related Interfaces
        • CreateAlarmPolicy
        • UpdateAlarmPolicy
        • DeleteAlarmPolicy
        • ValidateAlarmCondition
        • ValidateAlarmPolicySQL
        • EnableAlarmPolicy
        • DescribeAlarmRecord
        • DisableAlarmPolicy
        • DescribeAlarmPolicy
        • ListAlarmPolicy
        • ListAlarmRecord
        • ListAlarmExecutionStats
        • ListAlarmExecutions
      • LogStore Template-Related Interfaces
        • CreateLogStoreTemplate
        • UpdateLogStoreTemplate
        • DeleteLogStoreTemplates
        • DescribeLogStoreTemplates
        • DescribeLogStoreTemplate
      • Download Log Download Related Interfaces
        • Create Download Task CreateDownloadTask
        • Get Download Task List ListDownloadTask
        • Delete Download Task DeleteDownloadTask
        • Get Download Task Address GetDownloadTaskLink
        • Get Download Task Details DescribeDownloadTask
      • LogAlarm Related Interfaces
        • SetLogAlarmStatus
        • deleteLogAlarm
        • createLogAlarm
        • listLogAlarm
        • updateLogAlarm
        • BulkDeleteLogAlarm
        • PreviewAlarmLogRecord
        • getLogAlarm
        • BulkSetLogAlarmStatus
      • Transmission Task Related Interfaces
        • Create Task CreateTask
        • UpdateTask
      • Interfaces Compatible with Elasticsearch
        • ResolveIndex
        • FieldCaps
        • TermsEnum
        • AsyncSearch
    • SDK Reference
      • Go SDK
        • Overview
        • Initialization
        • Version Release Records
        • Project Operations
        • LogStore Operations
        • Install the SDK Package
        • LogStream Operations
        • LogRecord Operations
        • FastQuery Operations
        • LogShipper Operations
        • Index Operations
        • Download Task Operations
      • Java SDK
        • Overview
        • Install the SDK Package
        • LogRecord Operations
      • iOS SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android SDK
        • Overview
        • Quick start
        • Version Release Records
      • Android & iOS SDK Download
      • SDK Privacy Policy
      • SDK Developer Personal Information Protection Compliance Guide
    • Importing SLS Collection Configuration
  • FAQs
    • Common Questions Overview
    • Fault-related questions
    • Configuration-related questions
  • Log Service Level Agreement SLA
  • Document center
  • arrow
  • BLS
  • arrow
  • Development Guide
  • arrow
  • API Reference
  • arrow
  • Alarm-Related Interfaces
  • arrow
  • CreateAlarmPolicy
Table of contents on this page
  • Description
  • Request
  • Response
  • Error code
  • Example

CreateAlarmPolicy

Updated at:2025-11-03

Description

Create an alarm policy to send alarm notification when alarm conditions are satisfied.

Request

  • Request syntax
Text
1POST /v1/alarm/policy HTTP/1.1
2Host: <Endpoint>
3Authorization: <Authorization String>
4Content-Type: application/json; charset=utf-8
5{
6  "name": <PolicyName>,
7}
  • Request headers

No additional headers are required beyond the standard request headers.

  • Request parameters
Parameter name Types Required or not Parameter location Description
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
1POST /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    // Alarm policy name, unique under the same user, required
7    "name": "policy-name",
8    
9    // List of monitor objects, optional. When all logstores share the target logstore, fill in this field
10    "objects": [
11        {
12            "project": "default", // Logstore project, default
13            "logStoreName": "test-logstore-52"  // Logstore name
14        },
15    ],
16    
17    // List of execution statements, required
18    "targets": [
19        {
20            // Execution statement, required
21            "query": "select sum(age) as age",
22            // Query start time offset, required, value range: [-1440, 0)
23            "startTimeOffsetMinute": -1440,
24            // Query end time offset, required, value range: (startTimeOffsetMinute, 0]
25            "endTimeOffsetMinute": 0,
26            
27            // Target logstore, optional. When each execution statement specifies a logstore separately, fill in this field
28            "object": {
29                "logStoreName": "test-logstore-52"  // Logstore name
30            }
31        }
32    ],
33    
34    // List of trigger conditions, required
35    "triggerConditions": [
36        {
37            // Alarm level, required, options:
38            // INFO     - Notification,
39            // WARN     - Warning
40            // CRITICAL - Critical
41            "level": "WARN",
42            
43            // Trigger condition expression, required
44            "condition": "$1.age > 1"
45        }
46    ],
47    
48    // Group trigger, optional
49    "groups": ["$1.age", "$1.salary"],
50    
51    // Execution cycle, required. Either fixed interval or specified time must be set, but not both
52    "schedule": {
53        // Fixed interval, unit: minutes, value range [1, 1440]
54        "intervalMinute": 1,
55        
56        // Specified time, minutes of the day, value range [0, 1440)
57        "fixTimeMinute": 120, // In the example, 120 represents the 120th minute of the day, i.e., 2:00 AM
58        // Fixed time frequency; 0: Daily  1~7 represents a specific day in a week
59        "dayOfWeek": 0
60    },
61    
62    // Continuous trigger threshold, number of consecutive times the threshold is triggered before an alarm is raised, required
63    "pendingCount": 1,
64    
65    // Repeat alarm interval, unit: minutes, default value: 0, which means repeat alarm is disabled
66    "repeatIntervalMinute": 5,
67    
68    // Whether to notify after recovery, true: no notification, false: notification, default
69    "recoverWithoutNotice": true,
70    
71    // Policy activation status, options:
72    // ENABLED  - Enabled
73    // DISABLED - Disabled
74    "state": "ENABLED",
75        
76    // Notification activation status, options:
77    // ENABLED  - Enabled
78    // DISABLED - Disabled
79    "noticeState": "ENABLED",
80    
81    // Alarm notification template list, required
82    "notices": [
83        {
84            // BCM alarm template ID, required
85            "id": "testNotice"  
86        }
87    ],
88    
89    // Whether to include original logs in alarm notifications, optional
90    "noticeRawLogs" : [
91        {    
92            // Configuration type, required
93            // REF    - Associated execution statement
94            // CUSTOM - Custom search statement
95            "type" : "CUSTOM",
96            
97            // If type=REF, required, indicating the referenced execution statement sequence number, counting from 0
98            "refTarget" : 1,
99            
100            // If type=CUSTOM, fill in the custom execution statement
101            "customTarget": {
102                // Execution statement, required
103                "query": "select sum(age) as age",
104                // Query start time offset, required, value range: [-1440, 0)
105                "startTimeOffsetMinute": -1440,
106            // Query end time offset, required, value range: (startTimeOffsetMinute, 0]
107                "endTimeOffsetMinute": 0,
108            
109                // Target logstore, optional. When each execution statement specifies a logstore separately, fill in this field
110                "object": {
111                    "logStoreName": "test-logstore-52"  // Logstore name
112                }
113            }
114                        
115            // List of field names displayed in the original logs, optional. If not filled, all fields will be displayed.
116            "columns": ["requestid", "status"],
117            
118            // Number of logs displayed, maximum: 5, required
119            "limit" : 4,
120        }
121    ]
122}
  • 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}

Previous
Log Shipper LogShipper Related Interfaces
Next
UpdateAlarmPolicy