All Products
Search
Document Center

Application Real-Time Monitoring Service:CreatePrometheusAlertRule

Last Updated:Aug 28, 2026

Creates a Prometheus alert rule for a specified cluster.

Operation description

Note

Use CreateOrUpdateAlertRule instead to create Prometheus alert rules.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the cluster.

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. Valid values:

  • 99: custom alert

  • 101: Prometheus Service alert

101

NotifyType

string

No

The notification method. Valid values:

  • ALERT_MANAGER: notifications are sent by Operation Center. This is the default value.

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

ALERT_MANAGER

DispatchRuleId

integer

No

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

10282

Expression

string

Yes

The alert rule expression, which must follow 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 of the alert condition before the alert is triggered. Valid values: 1 to 1440. Unit: minutes.

10m

Message

string

Yes

The content of the alert notification message. You can reference tags in the {{$labels.xxx}} format.

${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%

Labels

string

No

The tags of the alert rule in JSON format. Specify the name and value of each tag.

[{"Value": "critical","Name": "severity"}]

Annotations

string

No

The annotations of the alert rule in JSON format. Specify the name and value of each annotation.

[{"Value": "xxx","Name": "description"}]

Tags

array<object>

No

The tags of the alert rule.

object

No

The tag.

Key

string

No

The tag key.

type

Value

string

No

The tag value.

value1

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

9FEA6D00-317F-45E3-9004-7FB8B0B7****

PrometheusAlertRule

object

The details of the alert rule.

Status

integer

Indicates whether the alert rule is enabled. Valid values:

  • 1: enabled.

  • 0: disabled.

1

Type

string

The type of the alert rule.

Kubernetes组件告警

NotifyType

string

The notification method. Valid values:

  • ALERT_MANAGER: notifications are sent by Operation Center.

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

ALERT_MANAGER

Expression

string

The alert rule 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

string

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

${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%

Duration

string

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

10m

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 cluster ID.

c0bad479465464e1d8c1e641b0afb****

Labels

array<object>

The tags of the alert rule.

object

The tag.

Name

string

The tag name.

severity

Value

string

The tag value.

critical

Annotations

array<object>

The annotations of the alert rule.

object

The annotation.

Name

string

The annotation name.

message

Value

string

The annotation value.

${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%

Code

integer

The HTTP status code. A value of 200 indicates success.

200

Success

boolean

Indicates whether the request was successful.

true

Message

string

The response message.

success

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": "10m",
    "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,
  "Success": true,
  "Message": "success"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.