tencent cloud

APIs

CreateAlarm

下载
聚焦模式
字号
最后更新时间: 2026-06-10 15:03:26

1. API Description

Domain name for API request: cls.intl.tencentcloudapi.com.

This API is used to create an alarm policy.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateAlarm.
Version Yes String Common Params. The value used for this API: 2020-10-16.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
Name Yes String

Alarm policy name. Supports a maximum of 255 bytes. Unsupported '

AlarmTargets.N Yes Array of AlarmTarget

Monitoring object list.

MonitorTime Yes MonitorTime

Monitoring task execution time point.

TriggerCount Yes Integer

Duration cycle. An alarm is triggered after trigger conditions are constantly met for TriggerCount cycles. Minimum value is 1. Maximum value is 2000.

AlarmPeriod Yes Integer

Alarm repeat cycle in minutes. Value ranges from 0 to 1440.

Condition No String

Trigger conditions for sending alarm notifications
Note:

  • Condition and AlarmLevel are one set of configurations, and MultiConditions are another set of configurations. The two sets are mutually exclusive.
AlarmLevel No Integer

Alarm level
0: Warning; 1: Info; 2: Critical.
Note:

  • Defaults to 0 if left empty.
  • Condition and AlarmLevel are one set of configurations, and MultiConditions are another set of configurations. The two sets are mutually exclusive.
MultiConditions.N No Array of MultiCondition

Multiple trigger conditions
Note:

  • Condition and AlarmLevel are one set of configurations, and MultiConditions are another set of configurations. These two sets are mutually exclusive.
Status No Boolean

Whether to enable alarm policy.
Default value is true

MessageTemplate No String

User-defined alarm content

CallBack No CallBackInfo

user-defined callback

Analysis.N No Array of AnalysisDimensional

Multi-dimensional analysis

GroupTriggerStatus No Boolean

Group trigger status.
false by default

GroupTriggerCondition.N No Array of String

Group trigger conditions.

Tags.N No Array of Tag

Tag description list. Tags can be bound to the corresponding alarm policy simultaneously by specifying this parameter.

It supports up to 10 tag key-value pairs, which cannot be duplicate.

MonitorObjectType No Integer

Monitored object type. 0: Common monitoring object for execution statements; 1: Each execution statement selects its own monitored object.
Defaults to 0 if left blank.
When the value is 1, the number of elements in AlarmTargets must not exceed 10, and the Numbers in AlarmTargets must be consecutive positive integers starting from 1 without duplication.

Classifications.N No Array of AlarmClassification

Alert additional classification information list.
Number of Classifications elements must not exceed 20.
The Key of Classifications elements cannot be empty, must be unique, length cannot exceed 50 characters, and complies with the regular expression ^[a-z]([a-z0-9_]{0,49})$.
Value of Classifications elements cannot exceed 200 characters.

AlarmNoticeIds.N No Array of String

List of associated log service alarm notification channel groups. - Search the associated alarm notification channel group list via Get Notification Channel Group List, mutually exclusive with MonitorNotice.

MonitorNotice No MonitorNotice

The associated observability platform notification template is mutually exclusive with the AlarmNoticeIds parameter and cannot be used simultaneously.

3. Output Parameters

Parameter Name Type Description
AlarmId String

Alert policy ID.

RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Create alarm policy

Create alarm policy

Input Example

POST / HTTP/1.1
Host: cls.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateAlarm
<Common request parameters>

{
"Name": "test-p0 Alarm Policy"
    "AlarmTargets": [
        {
            "Query": "level:error | select count(*) as cnt limit 100",
            "Number": 1,
            "StartTimeOffset": -15,
            "EndTimeOffset": 0,
            "SyntaxRule": 1,
            "LogsetId": "ad5a574c-xxxx-xxxx-bb67-990d0cb9747a",
            "TopicId": "test-cos-1254111111"
        }
    ],
    "MonitorTime": {
        "Type": "Period",
        "Time": 1
    },
    "TriggerCount": 1,
    "AlarmPeriod": 15,
    "AlarmNoticeIds": [
        "notice-1a2c6c17-xxxx-xxxx-81be-25248ada5a4c"
    ],
    "Status": true,
    "MessageTemplate": "{{.Label}}",
    "CallBack": {
        "Headers": [],
        "Body": ""
    },
    "Analysis": [
        {
"Name": "Custom Search and Analysis"
            "Type": "query",
            "Content": "level:error | select err limit 100",
            "ConfigInfo": [
                {
                    "Key": "SyntaxRule",
                    "Value": "1"
                }
            ]
        }
    ],
    "GroupTriggerStatus": false,
    "GroupTriggerCondition": [],
    "Tags": [],
    "MonitorObjectType": 0,
    "Classifications": [],
    "MultiConditions": [
        {
            "Condition": "[$1.__QUERYCOUNT__]> 10000",
            "AlarmLevel": 0
        }
    ]
}

Output Example

{
    "Response": {
        "AlarmId": "alarm-37cd7e19-xxxx-xxxx-82cc-00713ef449f6",
        "RequestId": "ab6b1233-xxxx-xxxx-91f5-c6fad91966fe"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
InternalError Internal error.
InvalidParameter Incorrect parameter.
InvalidParameter.AlarmConflict The alarm policy already exists.
MissingParameter Missing parameter.
OperationDenied Operation denied.
OperationDenied.ACLFailed ACL verification failed.
OperationDenied.AccountDestroy The account has been terminated.
OperationDenied.AccountIsolate The account has overdue payments.
OperationDenied.AccountNotExists The account does not exist.
OperationDenied.AlarmNotSupportForSearchLow IA storage does not support alarms.
ResourceNotFound.AlarmNoticeNotExist The alarm notification template does not exist.
ResourceNotFound.TopicNotExist The log topic does not exist.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈