
Content is empty
If you don't find the content you expect, please try another search term
Last updated:2026-03-18 14:12:49
Call the CreateAlarmPolicy API to configure an alarm policy under the specified account.
Field | Value |
|---|---|
API Name | CreateAlarmPolicy |
Request Method | POST |
Endpoint |
|
VPC Internal Endpoint |
|
Version |
|
All requests must include the Common Request Parameters. The table below lists only the API-specific parameters.
Parameter | Required | Type | Description |
|---|---|---|---|
| Yes | String | Fixed value: |
| Yes | String | Fixed value: |
| Yes | String | Name of the alarm policy. |
| Yes | Integer | Cloud service category. See Cloud Service Categories for valid values. |
| Yes | Integer | Policy type.
|
| No | Integer | Resource binding type for the policy.
|
| No | Integer | Project group ID. Required when |
| No | Array | List of instance IDs. Required when |
| Yes | Array of TriggerRuleObject | Rules that define when an alarm is triggered. See TriggerRule sub-table below. |
| No | Array of UserNoticeObject | Alarm notification recipients and delivery methods. See UserNotice sub-table below. |
| No | String[] | Webhook callback URLs for alarm notifications. Up to 5 URLs can be added. |
Parameter | Required | Type | Description |
|---|---|---|---|
| Yes | String | Statistical period in minutes. Examples: |
| Yes | String | Statistical aggregation method. Supported values: |
| Yes | String | Comparison operator. Supported values: |
| Yes | String | Threshold value that triggers the alarm. |
| Yes | String | Display name of the monitoring metric. Example: |
| Yes | String | Identifier key of the monitoring metric. Example: |
| Yes | String | Unit of the monitoring metric. Example: |
| Yes | Integer | Number of consecutive statistical periods that must breach the threshold before an alarm is triggered. |
| No | String | Start time of the policy's effective window. Format: |
| No | String | End time of the policy's effective window. Format: |
| Yes | Integer | Interval between repeated alarm notifications, in minutes. Examples: |
| Yes | Integer | Maximum number of alarm notifications to send. Valid range: |
Parameter | Required | Type | Description |
|---|---|---|---|
| Yes | Integer | Alarm notification delivery method. |
| Yes | Integer | Type of alarm contact. |
| Yes | Integer | ID of the contact or contact group. See Get Contacts and Get Contact Groups for details. |
Field | Type | Description |
|---|---|---|
| String | Unique request ID. |
| Integer | The ID of the newly created alarm policy. |
Replace
${region}with the appropriate region code. See: Region Reference. Replace${CommonParams}with the appropriate common parameters. See: Common Parameters.
curl -X POST 'https://monitor.${region}.api.ksyun.com/?Action=CreateAlarmPolicy&Version=2022-01-01' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'host: monitor.api.ksyun.com' \
-H 'cache-control: no-cache' \
-H ${CommonParams} \
-d '{
"PolicyName": "qa",
"ProductType": 0,
"PolicyType": 0,
"ResourceBindType": 3,
"InstanceIds": [
"XXXX-XXXX-XXXXXXXXXXXXX01",
"XXXX-XXXX-XXXXXXXXXXXXX02",
],
"TriggerRules": [
{
"RuleId": 0,
"ItemKey": "system.cpu.load",
"ItemName": "CPU15分钟平均负载",
"Method": "avg",
"Period": "1m",
"Compare": ">",
"TriggerValue": "1",
"Units": "",
"DisplayUnits": "",
"Points": 1,
"EffectBT": "00:00",
"EffectET": "23:59",
"Interval": 5,
"MaxCount": 5
}
],
"UserNotice": [
{
"ContactWay": 3,
"ContactFlag": 2,
"ContactId": 4423
}
],
"URLNotice": [
"https://monitor.console.ksyun.com/callback/notify"
]
}'Parameter | Value in Example | Explanation |
|---|---|---|
|
| Policy name. |
|
| Cloud service category code. See Cloud Service Categories. |
|
| Standard policy (non-default). |
|
| Manually selected instances — |
| Two instance UUIDs | The specific instances this policy applies to. |
|
| Monitors the 15-minute average CPU load. |
|
| Uses the average aggregation method. |
|
| 1-minute statistical period. |
|
| Triggers when the metric value exceeds the threshold. |
|
| Alarm fires when the 15-minute avg CPU load exceeds |
|
| Triggers after 1 consecutive breach period. |
|
| Policy is active 24 hours a day. |
|
| Repeat alarm notification every 5 minutes. |
|
| Send a maximum of 5 alarm notifications. |
|
| Notify via both Email and SMS. |
|
| Contact type is an individual contact. |
|
| ID of the individual contact to notify. |
| Webhook URL | Alarm callback URL for webhook notification. |
JSON Format
{
"requestId": "af0f9264-dbd4-4b41-aef7-b9b40b36d1a0",
"data": {
"policyId": 26562
}
}XML Format
<RequestID>53df9d17-9bd6-4e3c-a9be-fda6ae02d4dd</RequestID>
<Data>
<PolicyId>26565</PolicyId>
</Data>JSON Format
{
"requestId": "af0f9264-dbd4-4b41-aef7-b9b40b36d1a0",
"error": {
"type": "sender",
"code": "InvalidParameterValue",
"message": "Invalid `ProductType` parameter value."
}
}The table below lists only the error codes specific to this API's business logic. For all other error codes, refer to Common Error Codes.
Pure Mode