首页 UpdatePrometheusAlertRule

UpdatePrometheusAlertRule

更新时间: 2026-06-05 07:03:24

Updates a Prometheus alert rule.

Operation description

UpdatePrometheusAlertRule 接口已不再维护,请使用 CreateOrUpdateAlertRule 接口创建或修改告警规则。

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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: Alert notifications are sent by Operation Center. This is the default value.

  • DISPATCH_RULE: Alert notifications are sent based on the specified notification policy.

ALERT_MANAGER

DispatchRuleId

integer

No

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

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: The alert rule is enabled.

  • 0: The alert rule is disabled.

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: Alert notifications are sent by Operation Center.

  • DISPATCH_RULE: Alert notifications are sent based on the specified notification policy.

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

  • false

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.

阿里云首页 可观测监控 Prometheus 版 相关技术圈