Updates an alert rule.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes UpdatePrometheusAlertRule

The operation that you want to perform. Set the value to UpdatePrometheusAlertRule.

RegionId String Yes cn-hangzhou

The ID of the region.

AlertName String Yes Prometheus_Alert

The name of the alert rule.

ClusterId String Yes c0bad479465464e1d8c1e641b0afb****

The ID of the cluster.

Type String No Kubernetes component alert

The type of the alert rule.

NotifyType String No ALERT_MANAGER

The method of that is used to send alert notifications. Valid values:

  • ALERT_MANAGER: Alert notifications are sent by Operation Center.
  • DISPATCH_RULE: Alert notifications are sent based on the specified notification policy.
DispatchRuleId Long No 10282

The ID of the notification policy. This parameter is required if the NotifyType parameter is set to DISPATCH_RULE.

Expression String Yes 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

The alert rule expression that follows the PromQL syntax.

Duration String Yes 1m

The duration of the alert. Valid values: 1 to 1440. Unit: minutes.

Message String Yes The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%

The message of the alert notification. Tags can be referenced in the {{$labels.xxx}} format.

Labels String No [{"Value": "critical","Name": "severity"}]

The tags that are described in a JSON string. You must specify the name and value of each tag.

Annotations String No [{"Value": "xxx","Name": "description"}]

The annotations that are described in a JSON string. You must specify the name and value of each annotation.

AlertId Long Yes 3888704

The ID of the alert rule. You can call the ListPrometheusAlertRules operation to query the ID of the alert rule.

Response parameters

Parameter Type Example Description
RequestId String 9FEA6D00-317F-45E3-9004-7FB8B0B7****

The ID of the request.

PrometheusAlertRule Object

The struct returned.

Status Integer 1

Indicates whether the alert rule is enabled. Valid values:

  • 1: The alert rule is enabled.
  • 0: The alert rule is disabled.
Type String Kubernetes component alert

The type of the alert rule.

NotifyType String ALERT_MANAGER

The method of that is used to send alert notifications. Valid values:

  • ALERT_MANAGER: Alert notifications are sent by Operation Center.
  • DISPATCH_RULE: Alert notifications are sent based on the specified notification policy.
Expression String 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

The expression of the alert rule.

Message String The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%

The message of the alert notification. Tags can be referenced in the {{$labels.xxx}} format.

Duration String 1m

The duration of the alert. Valid values: 1 to 1440. Unit: minutes.

DispatchRuleId Long 10282

The ID of the notification policy.

AlertName String Prometheus_Alert

The name of the alert rule.

AlertId Long 3888704

The ID of the alert rule.

ClusterId String c0bad479465464e1d8c1e641b0afb****

The ID of the cluster.

Labels Array of Label

The tags of the alert rule.

Name String severity

The name of the tag.

Value String critical

The value of the tag.

Annotations Array of Annotation

The annotations of the alert rule.

Name String message

The name of the annotation.

Value String The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%

The value of the annotation.

Examples

Sample requests

http(s)://[Endpoint]/?Action=UpdatePrometheusAlertRule
&AlertId=3888704
&AlertName=Prometheus_Alert
&ClusterId=c0bad479465464e1d8c1e641b0afb****
&Duration=1m
&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}} exceeds 80%. Current value: {{$value}}%
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<UpdatePrometheusAlertRuleResponse>
    <RequestId>9FEA6D00-317F-45E3-9004-7FB8B0B7****</RequestId>
    <PrometheusAlertRule>
        <Status>1</Status>
        <NotifyType>ALERT_MANAGER</NotifyType>
        <Type>Kubernetes component alert</Type>
        <AlertId>3888704</AlertId>
        <AlertName>Prometheus_Alert</AlertName>
        <Message>The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%</Message>
        <ClusterId>c0bad479465464e1d8c1e641b0afb****</ClusterId>
        <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))&amp;gt;75</Expression>
        <DispatchRuleId>10282</DispatchRuleId>
        <Duration>1m</Duration>
        <Labels>
            <Value>critical</Value>
            <Name>severity</Name>
        </Labels>
        <Annotations>
            <Value>The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%</Value>
            <Name>message</Name>
        </Annotations>
    </PrometheusAlertRule>
</UpdatePrometheusAlertRuleResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
  "PrometheusAlertRule" : {
    "Status" : 1,
    "NotifyType" : "ALERT_MANAGER",
    "Type" : "Kubernetes component alert",
    "AlertId" : 3888704,
    "AlertName" : "Prometheus_Alert",
    "Message" : "The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%",
    "ClusterId" : "c0bad479465464e1d8c1e641b0afb****",
    "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))&amp;gt;75",
    "DispatchRuleId" : 10282,
    "Duration" : "1m",
    "Labels" : {
      "Value" : "critical",
      "Name" : "severity"
    },
    "Annotations" : {
      "Value" : "The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%",
      "Name" : "message"
    }
  }
}