tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary

Using API to Create Alarm Policy

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-10-27 17:54:34
This document describes how to use CreateAlarmPolicyAPI and Binding Policy ObjectAPI to create alarm policies and bind alarm objects.

Preparations

Before calling the Create Alarm PolicyAPI , you need to prepare the following information.

Preparing personal key

1. Go to the API Key Management page in the CAM console.
2. Click Show to get the SecretKey.
Note:
If no key has been created, please click Create Key to create one.

Preparing alarm policy type

You can query all policy types through the DescribeAllNamespacesAPI in the following steps:
1. Log in to the API Explorer console and enter the input parameters as shown below:
Parameter
Description
SecretId, SecretKey
Enter the prepared `SecretId` and `SecretKey`
Region
Select the corresponding region
SceneType
Enter `ST_ALARM`
Module
Enter `monitor`
MonitorTypes.N
Optional
2. Click Online Call > Send Request to get the response, where Response.QceNamespacesNew.N.Id is the Namespace required by alarm policy creation.
Note:
Here, Namespace is the alarm policy type, which is different from the Tencent Cloud service namespace used to pull monitoring data.

Preparing metric list

You can query all alarm metrics under the policy type through the DescribeAlarmMetricsAPI.
1. Log in to the API Explorer console and enter the input parameters as shown below:
Parameter
Description
SecretId, SecretKey
Enter the prepared `SecretId` and `SecretKey`
Region
Select the corresponding region
Module
Enter `monitor`
MonitorType
Enter `MT_QCE`
Namespace
Enter the alarm policy type obtained in the "Preparing alarm policy type" step, i.e., `Response.QceNamespacesNew.N.Id` in the returned result
2. Click Online Call > Send Request on the right to get the response, where Response.Metrics.N lists all the alarm metrics under the policy type.

Preparing event list

You can query all the alarm events under the policy type through the DescribeAlarmEventsAPI.
1. Log in to the API Explorer console and enter the input parameters as shown below:
Parameter
Description
SecretId, SecretKey
Enter the prepared `SecretId` and `SecretKey`
Region
Select the corresponding region
Module
Enter `monitor`
Namespace
Enter the alarm policy type obtained in the "Preparing alarm policy type" step, i.e., `Response.QceNamespacesNew.N.Id` in the returned result
2. Click Online Call > Send Request to get the response, where `Response.Events.N.EventName` is the `EventName` required by alarm policy creation.

Directions

This document describes how to use APIs such as CreateAlarmPolicyAPI to create an alarm policy for CVM - basic monitoring with the following example.

Creating alarm policy

1. Log in to the API Explorer console.
2. Copy the prepared personal key into the corresponding SecretId and SecretKey text boxes.
3. Find Region in the Input Parameters section and select the relevant region.
4. Enter monitor in Module, a custom policy name in PolicyName, and MT_QCE in MonitorType.
5. Enter the alarm policy type obtained in the Preparing alarm policy type step above in Namespace. For example, the alarm policy type of CVM - basic monitoring is cvm_device.
6. In the CVM - basic monitoring use case, Remark and Enable are optional, while ProjectId is required.
Remark: remark, which is optional.
Enable: whether to enable the alarm policy. 0 indicates to disable, 1 indicates to enable, and the default value is 1. This parameter is optional.
ProjectId: project ID, which should be 0 for CVM - basic monitoring.
Note:
ProjectId is the project ID. -1 indicates no project, 0 indicates the default project, and the default value is -1. This parameter is optional depending on the policy type. For example, some alarm policy types don't have the concept of project (such as VPC), and the default value -1 can be used. If the alarm policy type has the concept of project (such as CVM - basic monitoring), an error will be reported if the default value -1 is passed in, and the input parameter should be changed to "0".
7. Configure Condition as shown below:
Parameter
Required
Description
IsUnionRule
Yes
Metric trigger condition operator. Valid values: 0 (OR), 1 (AND). OR means that the alarm will be sent when any condition is triggered, while AND means that the alarm will be sent when all conditions are triggered
Rules.N
Yes
List of alarm trigger conditions, which can be configured by referring to the `AlarmPolicyRule` parameter
MetricName: enter the `MetricName` (Metrics.N.MetricName) returned in the Preparing metric list step
Period: enter the `Period` (Metrics.N.MetricConfig.Period) returned in the Preparing metric list step
Operator: enter the `Operator` (Metrics.N.MetricConfig.Operator) returned in the Preparing metric list step
Value: enter a threshold without the unit, such as 80
ContinuePeriod: enter the `ContinuePeriod` (Metrics.N.MetricConfig.ContinuePeriod) returned in the Preparing metric list step
NoticeFrequency: set the alarm frequency in seconds. Parameter description: alarm interval in seconds. Valid values: 0 (do not repeat), 300 (alarm once every 5 minutes), 600 (alarm once every 10 minutes), 900 (alarm once every 15 minutes), 1800 (alarm once every 30 minutes), 3600 (alarm once every hour), 7200 (alarm once every 2 hours), 10800 (alarm once every 3 hours), 21600 (alarm once every 6 hours), 43200 (alarm once every 12 hours), 86400 (alarm once every day)
IsPowerNotice: set whether the alarm frequency grows exponentially. Valid values: 0 (no), 1 (yes)
Other parameters can be left empty
8. If you want to trigger an event alarm, you need to configure the EventCondition parameter. Under EventCondition, you only need to enter the EventName obtained in the Preparing event list step in Rules.N.MetricName, and you can leave other parameters empty.
9. Enter the alarm notification template ID in NoticeIds.N, such as notice-qvq836vc, which can be obtained through the DescribeAlarmNoticesAPI.
10. After entering the above parameters, click Online Call > Send Request. The following figure shows the successful creation of the alarm policy for CVM - basic monitoring.
11. After the creation is successful, you can view the alarm policy on the Alarm Policy page in the Tencent Cloud Observability Platform console.

Binding alarm object

1. Log in to the API Explorer console.
2. Copy the prepared personal key into the corresponding SecretId and SecretKey text boxes.
3. Find Region in the Input Parameters section and select the relevant region.
4. Enter monitor in Module.
5. Enter 0 in GroupId.
6. Enter either the InstanceGroupId or Dimensions as detailed below:
InstanceGroupId: instance group ID. If you want to bind alarm objects by instance group, you need to pass in the instance group ID (such as 1234), which can be found on the instance group page in the Tencent Cloud Observability Platform console by clicking the corresponding instance name as shown below:
Dimensions.N: if you want to bind an alarm policy by instance ID, you need to enter Dimensions as detailed below:
Parameter
Description
RegionId, Region
Please see the instance region description; for example, for the Guangzhou region, `RegionId` is `1`, and `Region` is `gz`
Dimensions
Enter the CVM instance ID, which can be obtained through the DescribeInstancesAPI API. The input parameter format is {"unInstanceId":"ins-xxxxxxxx'"}
EventDimensions
Enter the globally unique instance ID, which can be obtained through the DescribeInstancesAPI API. The input parameter format is {"uuid":"9d51a69e-0e4a-4120-ae58-9c073c851e24"}
7. Enter the PolicyId (Response.PolicyId) returned in the Creating alarm policy step in PolicyId, such as policy-zg2sk27j.
8. After entering the above parameters, click Online Call > Send Request. The following figure shows that the alarm policy is successfully bound.
9. After the creation is successful, you can view the number of instances associated with the corresponding alarm policy on the Alarm Policy page in the Tencent Cloud Observability Platform console.


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백