This document describes how to use CreateAlarmPolicyAPI and Binding Policy ObjectAPI to create alarm policies and bind alarm objects.
Before calling the Create Alarm PolicyAPI , you need to prepare the following information.
SecretKey
.Note:If no key has been created, please click Create Key to create one.
You can query all policy types through the DescribeAllNamespacesAPI in the following steps:
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 |
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.
You can query all alarm metrics under the policy type through the DescribeAlarmMetricsAPI.
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 |
Response.Metrics.N
lists all the alarm metrics under the policy type. You can query all the alarm events under the policy type through the DescribeAlarmEventsAPI.
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 |
This document describes how to use APIs such as CreateAlarmPolicyAPI to create an alarm policy for CVM - basic monitoring with the following example.
Log in to the API Explorer console.
Copy the prepared personal key into the corresponding SecretId
and SecretKey
text boxes.
Find Region in the Input Parameters section and select the relevant region.
Enter monitor
in Module, a custom policy name in PolicyName, and MT_QCE
in MonitorType.
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
.
In the CVM - basic monitoring use case, Remark
and Enable
are optional, while ProjectId
is required.
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".
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
|
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.
Enter the alarm notification template ID in NoticeIds.N
, such as notice-qvq836vc, which can be obtained through the DescribeAlarmNoticesAPI.
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.
After the creation is successful, you can view the alarm policy on the Alarm Policy page in the Cloud Monitor console.
Log in to the API Explorer console.
Copy the prepared personal key into the corresponding SecretId
and SecretKey
text boxes.
Find Region in the Input Parameters section and select the relevant region.
Enter monitor
in Module.
Enter 0 in GroupId.
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 Cloud Monitor console by clicking the corresponding instance name as shown below:
Dimensions.N: if you wany 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"} |
Enter the PolicyId
(Response.PolicyId) returned in the Creating alarm policy step in PolicyId
, such as policy-zg2sk27j
.
After entering the above parameters, click Online Call > Send Request. The following figure shows that the alarm policy is successfully bound.
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 Cloud Monitor console.
Was this page helpful?