Promo Center

50% off for new user

Direct Mail-46% off

Learn More

ListPrometheusAlertRules

Updated at: 2024-11-05 06:52

Queries the alert rules created for a Prometheus instance.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
OperationAccess levelResource typeCondition keyAssociated operation
arms:ListPrometheusAlertRuleslist
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ParameterTypeRequiredDescriptionExample
NamestringNo

The name of the alert rule.

Prometheus_Alert
RegionIdstringYes

The region ID of the instance.

cn-hangzhou
ClusterIdstringYes

The ID of the cluster.

c0bad479465464e1d8c1e641b0afb****
TypestringNo

The type of the alert rule.

Custom
StatusintegerNo

Specifies whether the alert rule is enabled. Valid values:

  • 1: enables the alert rule.
  • 0: disables the alert rule.
1
MatchExpressionsstringNo

The tag match conditions that are described in a JSON string. For more information about this parameter, see the Additional description of the MatchExpressions parameter section.

[{"key":"severity","value":"critical","operator":"re"}]
Tagsarray<object>No

The tags.

objectNo

The tag.

KeystringNo

The tag key.

owner
ValuestringNo

The tag value.

zhangsan

Additional description of the MatchExpressions parameter

JSON string example and description

[
{
    "key":"severity",                           // The key of the tag. 
    "value":"critical",                           // The value of the tag. 
    "operator":"re"                           // eq: equals to. re: matches a regular expression. 
}
]

Response parameters

ParameterTypeDescriptionExample
ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

9FEA6D00-317F-45E3-9004-7FB8B0B7****
PrometheusAlertRulesarray<object>

The returned struct.

PrometheusAlertRuleobject

The returned struct.

Statusinteger

Indicates whether the alert rule is enabled. Valid values:

  • 1: The alert rule is enabled.
  • 0: The alert rule is disabled.
1
Typestring

The type of the alert rule.

Custom
NotifyTypestring

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

  • ALERT_MANAGER: Alert notifications are sent by Operation Center.
  • DISPATCH_RULE: Alert notifications are
ALERT_MANAGER
Expressionstring

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
Messagestring

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

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

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

1m
DispatchRuleIdlong

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

10282
AlertNamestring

The name of the alert rule.

Prometheus_Alert
AlertIdlong

The ID of the alert rule.

3888704
ClusterIdstring

The ID of the cluster.

c0bad479465464e1d8c1e641b0afb****
Labelsarray<object>

The tags of the alert rule.

Labelobject

The tag of the alert rule.

Namestring

The name of the tag.

severity
Valuestring

The value of the tag associated with the instance.

critical
Annotationsarray<object>

The annotations of the alert rule.

Annotationobject

The annotation of the alert rule.

Namestring

The name of the annotation.

message
Valuestring

The value of the annotation.

The CPU utilization of ${{$labels.pod_name}} exceeds 80%. Current value: {{$value}}%
Tagsarray<object>

The tags.

tagsobject

The tag.

Keystring

The tag key.

key
Valuestring

The tag value.

value
Codelong

The HTTP status code. The status code 200 indicates that the request was successful. Other status codes indicate that the request failed.

200
Messagestring

The returned message.

success
Successboolean

Indicates whether the request was successful.

True

Examples

Sample success responses

JSONformat

{
  "RequestId": "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
  "PrometheusAlertRules": [
    {
      "Status": 1,
      "Type": "Custom",
      "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}} exceeds 80%. Current value: {{$value}}%\n",
      "Duration": "1m",
      "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}} exceeds 80%. Current value: {{$value}}%\n"
        }
      ],
      "Tags": [
        {
          "Key": "key",
          "Value": "value"
        }
      ]
    }
  ],
  "Code": 200,
  "Message": "success",
  "Success": true
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
Change timeSummary of changesOperation
2023-07-31The response structure of the API has changedView Change Details
2023-05-11API Description Update. The request parameters of the API has changed. The response structure of the API has changedView Change Details
  • On this page (1)
  • Debugging
  • Authorization information
  • Request parameters
  • Additional description of the MatchExpressions parameter
  • Response parameters
  • Examples
  • Error codes
  • Change history
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare