All Products
Search
Document Center

Application Real-Time Monitoring Service:GetAlertRules

Last Updated:May 09, 2024

Queries alert rules.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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
arms:GetAlertRulesRead
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
AlertIdsstringNo

The unique IDs of alert rules.

  • If you do not specify this parameter, the API operation does not filter alert rules based on their IDs.
  • If you specify this parameter, the API operation returns only the information of the specified alert rules. Other filter conditions also take effect.
Note When you call the GetAlertRules operation, you can specify other request parameters to obtain the AlertIds parameter from the response. Then, you can specify the AlertIds parameter to query the specified alert rules.
["12345"]
AlertNamesstringNo

The names of alert rules. When you create alert rules of the new version, you cannot specify duplicate names. However, existing alert rules may have duplicate names. Therefore, the AlertName parameter does not uniquely identify an alert rule.

  • If you do not specify this parameter, the API operation does not filter alert rules based on their names.
  • If you specify this parameter, the API operation returns only the information of the specified alert rules. Other filter conditions also take effect.
["test"]
RegionIdstringYes

The region ID.

cn-hangzhou
AlertTypestringYes

The type of the alert rule.

  • APPLICATION_MONITORING_ALERT_RULE: alert rule for Application Monitoring
  • BROWSER_MONITORING_ALERT_RULE: an alert rule for Browser Monitoring.
  • PROMETHEUS_MONITORING_ALERT_RULE: alert rule for Managed Service for Prometheus.
APPLICATION_MONITORING_ALERT_RULE
AlertStatusstringNo

The status of the alert rule. Valid values:

  • RUNNING
  • STOPPED
  • PAUSED
Note The PAUSED status indicates that the alert rule is abnormal and is actively paused by the system. The alert rule may be paused because that it is not unique or the associated cluster has been deleted.
RUNNING
ClusterIdstringNo

The ID of the monitored cluster.

ceba9b9ea5b924dd0b6726d2de6******
ProductCodestringNo

You do not need to configure this parameter.

null
PagelongYes

The number of the page to return.

1
SizelongYes

The number of alert rules to return on each page.

20
Tagsobject []No

The list of tags.

KeystringNo

The tag key.

type
ValuestringNo

The tag value.

prod

Response parameters

ParameterTypeDescriptionExample
object

The struct returned.

RequestIdstring

The request ID.

337B8F7E-0A64-5768-9225-E9B3CF******
PageBeanobject

The pages returned.

Totallong

The total number of queried alert rules.

1
Pagelong

The number of pages returned.

1
Sizelong

The number of alert rules returned per page.

20
AlertRulesobject []

The list of alert rules.

AlertIdfloat

The ID of the alert rule.

5730***
AlertNamestring

The name of the alert rule.

arms-test
UserIdstring

The ID of the Alibaba Cloud account to which the resource belongs.

1131971649******
RegionIdstring

The region ID.

cn-hangzhou
AlertTypestring

The type of the alert rule.

  • APPLICATION_MONITORING_ALERT_RULE: alert rule for Application Monitoring
  • BROWSER_MONITORING_ALERT_RULE: alert rule for Browser Monitoring
  • PROMETHEUS_MONITORING_ALERT_RULE: alert rule for Managed Service for Prometheus
APPLICATION_MONITORING_ALERT_RULE
AlertStatusstring

The status of the alert rule. Valid values:

  • RUNNING
  • STOPPED
  • PAUSED
Note The PAUSED status indicates that the alert rule is abnormal and is actively paused by the system. The alert rule may be paused because that it is not unique or the associated cluster has been deleted.
RUNNING
CreatedTimelong

The time when the alert rule was created. The value is a timestamp. Unit: milliseconds.

1640333981000
UpdatedTimelong

The time when the alert rule was updated. The value is a timestamp. Unit: milliseconds.

1640333981000
Extendstring

The extended fields.

Note For existing Application Monitoring alert rules, the fields contained information such as contacts, alert template, and notification content.
{\\"alarmContext\\":\\"{\\\\\"content\\\\\":\\\\Alert name: $Alert name\\\\\\nFilter condition: $Filter condition\\\\\\nAlert time: $Alert time\\\\\\nAlert content: $Alert content\\\\\\nNote: The alert persists before you receive an email that reminds you to clear the alert. You will be reminded of the alert again 24 hours later. \\\\\",\\\\\"subTitle\\\\\":\\\\\"\\\\\"}\\",\\"alertWays\\":\\"\[0,1]\\",\\"contactGroupIds\\":\\"381,5075\\",\\"notice\\":\\"{\\\\\"endTime\\\\\":1480607940000,\\\\\"noticeEndTime\\\\\":1480607940000,\\\\\"noticeStartTime\\\\\":1480521600000,\\\\\"startTime\\\\\":1480521600000}\\"}
NotifyStrategystring

The name of the notification policy.

ALERT_MANAGER
Pidsarray

The process ID (PID) that was associated with the Application Monitoring or Browser Monitoring alert rule.

string

The PID of the application.

["b590lhguqs@40d8deedfa9******"]
AutoAddNewApplicationboolean

Indicates whether the alert rule was applied to new applications that were created in Application Monitoring or Browser Monitoring. Valid values:

  • true
  • false
false
MetricsTypestring

The metric type of the Application Monitoring or Browser Monitoring alert rule.

JVM
AlertRuleContentobject

The content of the Application Monitoring or Browser Monitoring alert rule.

Conditionstring

The relationship between multiple alert conditions specified for the Application Monitoring or Browser Monitoring alert rule. Valid values:

  • OR: meets any of the specified conditions.
  • AND: meets all the specified conditions.
OR
AlertRuleItemsobject []

The trigger conditions of the Application Monitoring or Browser Monitoring alert rule.

Nfloat

Indicates the last N minutes.

1
MetricKeystring

The metric of the alert condition.

appstat.jvm.non_heap_used
Aggregatestring

The aggregation method of the alert condition. Valid values:

  • AVG: calculates the average value
  • SUM: calculates the total value
  • MAX: selects the maximum value
  • MIN: selects the minimum value
AVG
Operatorstring

The comparison operator that was used to compare the metric value with the threshold. Valid values:

  • CURRENT_GTE: greater than or equal to
  • CURRENT_LTE: less than or equal to
  • PREVIOUS_UP: the increase percentage compared with the last period
  • PREVIOUS_DOWN: the decrease percentage compared with the last period
  • HOH_UP: the increase percentage compared with the last hour
  • HOH_DOWN: the decrease percentage compared with the last hour
  • DOD_UP: the increase percentage compared with the last day
  • DOD_DOWN: the decrease percentage compared with the last day
CURRENT_GTE
Valuestring

The threshold of the alert condition.

1
Filtersobject

The filter conditions of the Application Monitoring or Browser Monitoring alert rule.

DimFiltersobject []

The information about each filter condition of the Application Monitoring or Browser Monitoring alert rule.

FilterKeystring

The key of the filter condition.

rootIp
FilterOptstring

The logical operator of the filter condition.

ALL
FilterValuesarray

The details of the filter condition.

string

The value of the filter condition.

null
CustomSLSFiltersobject []

The custom filter condition of the Browser Monitoring alert rule.

Keystring

The key of the filter condition.

username
Optstring

The logical operator of the filter condition. Valid values:

  • =: equal to
  • not: not equal to
=
Valuestring

The value of the filter condition.

test
Tstring

Indicates the log type of Browser Monitoring. This field was not included in other filter conditions.

null
Showboolean

Indicates whether this filter condition was displayed on the frontend.

false
CustomSLSGroupByDimensionsarray

The information of the aggregation dimension.

string

The value of the aggregation dimension.

["page"]
CustomSLSWheresarray

The details of the custom filter condition.

string

The value of the custom filter condition.

["t like '%api%'"]
AlertCheckTypestring

The alert check type of the Prometheus alert rule. Valid values:

  • STATIC: static threshold value
  • CUSTOM: custom PromQL statement
STATIC
ClusterIdstring

The cluster ID of the Prometheus alert rule.

ceba9b9ea5b924dd0b6726d2de6******
AlertGrouplong

The ID of the alert contact group to which the alert rule belongs. Valid values:

  • -1: custom PromQL
  • 1: Kubernetes load
  • 15: Kubernetes node
1
PromQLstring

The PromQL statement of the Prometheus alert rule.

node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100
Durationstring

The duration of the Prometheus alert rule.

1
Levelstring

The severity level of the Prometheus alert rule.

  • P1: Alert notifications are sent for major issues that affect the availability of core business, have a huge impact, and may lead to serious consequences.
  • P2: Alert notifications are sent for service errors that affect the system availability with relatively limited impact.
  • P3: Alert notifications are sent for issues that may cause service errors or negative effects, or alert notifications for services that are relatively less important.
  • P4: Alert notifications are sent for low-priority issues that do not affect your business.
  • Default: Alert notifications are sent regardless of alert levels.
P2
Messagestring

The alert message of the Prometheus alert rule.

Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} CPU usage: {{$labels.metrics_params_opt_label_value}} {{$labels.metrics_params_value}}%. Current value: {{ printf "%.2f" $value }}%
Labelsobject []

The tags of the Prometheus alert rule.

Namestring

The tag key.

123
Valuestring

The tag value.

abc
Annotationsobject []

The annotations of the Prometheus alert rule.

Namestring

The key of the annotation.

123
Valuestring

The value of the annotation.

abc
Tagsobject []

The list of tags.

Keystring

The tag key.

type
Valuestring

The tag value.

prod

Examples

Sample success responses

JSONformat

{
  "RequestId": "337B8F7E-0A64-5768-9225-E9B3CF******",
  "PageBean": {
    "Total": 1,
    "Page": 1,
    "Size": 20,
    "AlertRules": [
      {
        "AlertId": 0,
        "AlertName": "arms-test",
        "UserId": "1131971649******",
        "RegionId": "cn-hangzhou",
        "AlertType": "APPLICATION_MONITORING_ALERT_RULE",
        "AlertStatus": "RUNNING",
        "CreatedTime": 1640333981000,
        "UpdatedTime": 1640333981000,
        "Extend": "{\\\\\"alarmContext\\\\\":\\\\\"{\\\\\\\\\\\"content\\\\\\\\\\\":\\\\\\\\Alert name: $Alert name\\\\\\\\\\\\nFilter condition: $Filter condition\\\\\\\\\\\\nAlert time: $Alert time\\\\\\\\\\\\nAlert content: $Alert content\\\\\\\\\\\\nNote: The alert persists before you receive an email that reminds you to clear the alert. You will be reminded of the alert again 24 hours later. \\\\\\\\\\\",\\\\\\\\\\\"subTitle\\\\\\\\\\\":\\\\\\\\\\\"\\\\\\\\\\\"}\\\\\",\\\\\"alertWays\\\\\":\\\\\"\\[0,1]\\\\\",\\\\\"contactGroupIds\\\\\":\\\\\"381,5075\\\\\",\\\\\"notice\\\\\":\\\\\"{\\\\\\\\\\\"endTime\\\\\\\\\\\":1480607940000,\\\\\\\\\\\"noticeEndTime\\\\\\\\\\\":1480607940000,\\\\\\\\\\\"noticeStartTime\\\\\\\\\\\":1480521600000,\\\\\\\\\\\"startTime\\\\\\\\\\\":1480521600000}\\\\\"}\n",
        "NotifyStrategy": "ALERT_MANAGER",
        "Pids": [
          "[\"b590lhguqs@40d8deedfa9******\"]"
        ],
        "AutoAddNewApplication": false,
        "MetricsType": "JVM",
        "AlertRuleContent": {
          "Condition": "OR",
          "AlertRuleItems": [
            {
              "N": 1,
              "MetricKey": "appstat.jvm.non_heap_used",
              "Aggregate": "AVG",
              "Operator": "CURRENT_GTE",
              "Value": "1"
            }
          ]
        },
        "Filters": {
          "DimFilters": [
            {
              "FilterKey": "rootIp",
              "FilterOpt": "ALL",
              "FilterValues": [
                "null"
              ]
            }
          ],
          "CustomSLSFilters": [
            {
              "Key": "username",
              "Opt": "=",
              "Value": "test",
              "T": "null",
              "Show": false
            }
          ],
          "CustomSLSGroupByDimensions": [
            "[\"page\"]"
          ],
          "CustomSLSWheres": [
            "[\"t like '%api%'\"]"
          ]
        },
        "AlertCheckType": "STATIC",
        "ClusterId": "ceba9b9ea5b924dd0b6726d2de6******",
        "AlertGroup": 1,
        "PromQL": "node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{} * 100",
        "Duration": "1",
        "Level": "P2",
        "Message": "Namespace: {{$labels.namespace}} / Pod: {{$labels.pod_name}} / Container: {{$labels.container}} CPU usage: {{$labels.metrics_params_opt_label_value}} {{$labels.metrics_params_value}}%. Current value: {{ printf \"%.2f\" $value }}%\n",
        "Labels": [
          {
            "Name": "123",
            "Value": "abc"
          }
        ],
        "Annotations": [
          {
            "Name": "123",
            "Value": "abc"
          }
        ],
        "Tags": [
          {
            "Key": "type",
            "Value": "prod"
          }
        ]
      }
    ]
  }
}

Error codes

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

Change history

Change timeSummary of changesOperation
2023-12-21The internal configuration of the API is changed, but the call is not affectedsee changesets
Change itemChange content
The internal configuration of the API is changed, but the call is not affected.
2023-05-11The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Tags
Output ParametersThe response structure of the API has changed.
2021-12-17The response structure of the API has changedsee changesets
Change itemChange content
Output ParametersThe response structure of the API has changed.
2021-12-06Add Operationsee changesets

More examples

Obtain the Browser Monitoring alert rules of the China (Hangzhou) region

Sample request

http(s)://[Endpoint]/?Action=GetAlertRules
&AlertIds=["12345"]
&AlertNames=["Default alert rule for Browser Monitoring"]
&RegionId=cn-hangzhou
&AlertType=BROWSER_MONITORING_ALERT_RULE
&AlertStatus=STOPPED
&Page=1
&Size=20
&Common request parameters

Sample response

{
  "PageBean": {
    "AlertRules": [
       {
                "AlertId": 12345,
                "AlertName": "Default alert rule for Browser Monitoring",
                "AlertRuleContent": {
                    "AlertRuleItems": [
                        {
                            "Aggregate": "AVG",
                            "MetricKey": "webstat.jsError.rate",
                            "N": 10,
                            "Operator": "CURRENT_GTE",
                            "Value": 0.2
                        },
                        {
                            "Aggregate": "SUM",
                            "MetricKey": "webstat.jsError.count",
                            "N": 10,
                            "Operator": "CURRENT_GTE",
                            "Value": 20.0
                        }
                    ],
                    "Condition": "AND"
                },
                "AlertStatus": "STOPPED",
                "AlertType": "BROWSER_MONITORING_ALERT_RULE",
                "AutoAddNewApplication": false,
                "CreatedTime": 1625824851000,
                "Extend": "{\"alarmContext\":\"{\\\"content\\\":\\\"Alert name: $Alert name\\\\\\\\nFilter condition: $Filter condition\\\\\\\\nAlert time: $Alert time\\\\\\\\nAlert content: $Alert content\\\\\\\\nNote: The alert persists before you receive an email that reminds you to clear the alert. You will be reminded of the alert again 24 hours later. \\\",\\\"subTitle\\\":\\\"\\\"}\",\"alertWays\":\"[0,1]\",\"contactGroupIds\":\"299\",\"notice\":\"{\\\"endTime\\\":1480607940000,\\\"noticeEndTime\\\":1480607940000,\\\"noticeStartTime\\\":1480521600000,\\\"startTime\\\":1480521600000}\"}",
                "Filters": {
                    "DimFilters": [
                        {
                            "FilterKey": "page",
                            "FilterOpt": "ALL",
                            "FilterValues": [
                                null
                            ]
                        }
                    ]
                },
                "MetricsType": "page",
                "Pids": [
                    "aokcdqn3ly@6a6c*******"
                ],
                "RegionId": "cn-hangzhou",
                "UpdatedTime": 1625824851000,
                "UserId": "1084*********"
            }
    ],
    "Size": 20,
    "Total": 1,
    "Page": 1
  },
  "RequestId": "A87CE2E7-8115-5A9C-8F4B-7C9DD7******"
}

Obtain the Prometheus alert rules of the China (Hangzhou) region

Sample request

http(s)://[Endpoint]/?Action=GetAlertRules
&AlertIds=["12345"]
&AlertNames=["Disk usage of the Elasticsearch node exceeds 85%"]
&RegionId=cn-hangzhou
&AlertType=PROMETHEUS_MONITORING_ALERT_RULE
&AlertStatus=RUNNING
&Page=1
&Size=20
&Common request parameters

Sample response

{
  "PageBean": {
    "AlertRules": [
      {
        "AlertName": "Disk usage of the Elasticsearch node exceeds 85%",
        "CreatedTime": 1643188668035,
        "Message": "Cluster ID: {{$labels.cluster_id}} Node IP address: {{$labels.node_id}} Disk usage  Current value {{ printf \"%.2f\" $value }}%\nFor more information, see https://elasticsearch.console.aliyun.com/{{$labels.region}}/instances/{{$labels.cluster_id}}/base",
        "ClusterId": "n9p9****",
        "PromQL": "arms_cms_es_node_disk_utilization > 85",
        "AlertCheckType": "CUSTOM",
        "AlertRuleContent": {},
        "NotifyStrategy": "ALERT_MANAGER",
        "Duration": 10,
        "Labels": [
          {
            "Value": "cms_es",
            "Name": "_aliyun_cloud_product"
          }
        ],
        "AlertType": "PROMETHEUS_MONITORING_ALERT_RULE",
        "AlertId": 12345,
        "AlertGroup": -1,
        "Filters": {},
        "Annotations": [
          {
            "Value": "Disk usage of the Elasticsearch node",
            "Name": "_aliyun_display_name"
          },
          {
            "Value": "Cluster ID: {{$labels.cluster_id}} Node IP address: {{$labels.node_id}} Disk usage  Current value {{ printf \"%.2f\" $value }}%\nFor more information, see https://elasticsearch.console.aliyun.com/{{$labels.region}}/instances/{{$labels.cluster_id}}/base",
            "Name": "message"
          },
          {
            "Value": "arms_cms_es_node_disk_utilization",
            "Name": "_aliyun_display_promql"
          }
        ],
        "Extend": "",
        "UserId": "10983*********",
        "AlertStatus": "RUNNING",
        "Level": "P6",
        "RegionId": "cn-hangzhou",
        "UpdatedTime": 1643188668035
      }
    ],
    "Size": 20,
    "Total": 1,
    "Page": 1
  },
  "RequestId": "A87CE2E7-8115-5A9C-8F4B-7C9DD7******"
}