Creates an alert rule.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
arms:CreatePrometheusAlertRule | create |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
RegionId | string | Yes | The ID of the region. | cn-hangzhou |
AlertName | string | Yes | The name of the alert rule. | Prometheus_Alert |
ClusterId | string | Yes | The ID of the cluster. | c0bad479465464e1d8c1e641b0afb**** |
Type | string | No | The type of the alert rule. Valid values:
| 101 |
NotifyType | string | No | The method that is used to send alert notifications. Valid values:
| ALERT_MANAGER |
DispatchRuleId | long | No | The ID of the notification policy. This parameter is required if the NotifyType parameter is set to | 10282 |
Expression | string | Yes | The expression of the alert rule. The expression must follow the PromQL syntax. | 100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \"pod_name\", \"$1\", \"pod\", \"(.*)\")) by (pod_name))>75 |
Duration | string | Yes | The duration. The value ranges from 1 to 1440 minutes. | 10m |
Message | string | Yes | The content of the alert notification. Tags can be referenced in the {{$labels.xxx}} format. | The CPU utilization of ${{$labels.pod_name}} has exceeded 80%. Current value: {{$value}}% |
Labels | string | No | The tags that are described in a JSON string. You must specify the name and value of each tag. | [{"Value": "critical","Name": "severity"}] |
Annotations | string | No | The annotations that are described in a JSON string. You must specify the name and value of each annotation. | [{"Value": "xxx","Name": "description"}] |
Tags | array<object> | No | The tags. | |
object | No | The tag. | ||
Key | string | No | The tag key. | type |
Value | string | No | The tag value. | value1 |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
"PrometheusAlertRule": {
"Status": 1,
"Type": "Kubernetes component alert\n",
"NotifyType": "ALERT_MANAGER",
"Expression": "100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \\\"pod_name\\\", \\\"$1\\\", \\\"pod\\\", \\\"(.*)\\\")) by (pod_name))>75",
"Message": "The CPU utilization of ${{$labels.pod_name}} has exceeded 80%. Current value: {{$value}}%\n",
"Duration": "10m",
"DispatchRuleId": 10282,
"AlertName": "Prometheus_Alert",
"AlertId": 3888704,
"ClusterId": "c0bad479465464e1d8c1e641b0afb****",
"Labels": [
{
"Name": "severity",
"Value": "critical"
}
],
"Annotations": [
{
"Name": "message",
"Value": "The CPU utilization of ${{$labels.pod_name}} has exceeded 80%. Current value: {{$value}}%"
}
]
},
"Code": 200,
"Success": true,
"Message": "success"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-07-31 | The response structure of the API has changed | View Change Details |
2023-05-11 | API Description Update. The request parameters of the API has changed | View Change Details |