UpdatePrometheusAlertRule
Updates a Prometheus alert rule.
Operation description
UpdatePrometheusAlertRule 接口已不再维护,请使用 CreateOrUpdateAlertRule 接口创建或修改告警规则。
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
arms:UpdatePrometheusAlertRule |
update |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. |
cn-hangzhou |
| AlertName |
string |
Yes |
The name of the alert rule. |
Prometheus_Alert |
| ClusterId |
string |
Yes |
The cluster ID. |
c0bad479465464e1d8c1e641b0afb**** |
| Type |
string |
No |
The type of the alert rule. |
Kubernetes组件告警 |
| NotifyType |
string |
No |
The method that is used to send alert notifications. Valid values:
|
ALERT_MANAGER |
| DispatchRuleId |
integer |
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. |
1 |
| Message |
string |
Yes |
The alert message. Tags can be referenced in the {{$labels.xxx}} format. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$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"}] |
| AlertId |
integer |
Yes |
The ID of the alert rule. You can call the ListPrometheusAlertRules operation to query the ID of the alert rule. |
3888704 |
| Tags |
array<object> |
No |
The tags. |
|
|
object |
No |
The tag. |
||
| Key |
string |
No |
The tag key. |
TestKey |
| Value |
string |
No |
The tag value. |
TestValue |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
9FEA6D00-317F-45E3-9004-7FB8B0B7**** |
| PrometheusAlertRule |
object |
The returned struct. |
|
| Status |
integer |
Indicates whether the alert rule is enabled. Valid values:
|
1 |
| Type |
string |
The type of the alert rule. |
Kubernetes组件告警 |
| NotifyType |
string |
The method of that is used to send alert notifications. Valid values:
|
ALERT_MANAGER |
| Expression |
string |
The expression of the alert rule. |
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 |
string |
The returned message. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Duration |
string |
The duration. The value ranges from 1 to 1440 minutes. |
1 |
| DispatchRuleId |
integer |
The ID of the notification policy. |
10282 |
| AlertName |
string |
The name of the alert rule. |
Prometheus_Alert |
| AlertId |
integer |
The ID of the alert rule. |
3888704 |
| ClusterId |
string |
The ID of the cluster. |
c0bad479465464e1d8c1e641b0afb**** |
| Labels |
array<object> |
The tags of the alert rule. |
|
|
object |
|||
| Name |
string |
The name of the tag. |
severity |
| Value |
string |
The value of the tag. |
critical |
| Annotations |
array<object> |
The annotation of the alert rule. |
|
|
object |
|||
| Name |
string |
The name of the annotation. |
message |
| Value |
string |
The value of the annotation. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Code |
integer |
The status code. The status code 200 indicates that the request was successful. |
200 |
| Message |
string |
The returned message. |
success |
| Success |
boolean |
Indicates whether the request was successful. Valid values:
|
True |
Examples
Success response
JSON format
{
"RequestId": "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
"PrometheusAlertRule": {
"Status": 1,
"Type": "Kubernetes组件告警",
"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": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%",
"Duration": "1",
"DispatchRuleId": 10282,
"AlertName": "Prometheus_Alert",
"AlertId": 3888704,
"ClusterId": "c0bad479465464e1d8c1e641b0afb****",
"Labels": [
{
"Name": "severity",
"Value": "critical"
}
],
"Annotations": [
{
"Name": "message",
"Value": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%"
}
]
},
"Code": 200,
"Message": "success",
"Success": true
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.