QueryAlertRules

Updated at:

Queries alert rules.

Operation description

This topic provides an example of querying the list of alert templates. The response shows that the list contains two alert templates: ECS_Template1 and ECS_Template2.

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

cms:QueryAlertRules

none

*All Resource

*

None None

Request syntax

POST /queryAlertRules HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

nextToken

string

No

The token that indicates the position from which the read operation starts. If this parameter is left empty, the read operation starts from the beginning.

123456

maxResults

integer

No

The maximum number of data records to return in the current read operation.

10

clientToken

string

No

The client token that is used to ensure idempotence.

xxxxx-xxxx-xxxx

body QueryAlertRulesInput

No

The request body for querying alert rules.

queryJson

string

No

The query filter conditions in JSON string format. The field semantics are the same as those in the request body. Supported fields include filter (such as uuid, displayName, labels, status, and enabled, where sibling fields use the AND logical operator), pagination (pageNumber and pageSize), and workspace. You can specify either this parameter or the body parameter. If both are specified, the body parameter takes precedence.

{"filter":{"displayName":{"contains":"my-rule"}},"pagination":{"pageNumber":1,"pageSize":20}}

Response elements

Element

Type

Description

Example

ServerResponseQueryAlertRulesResult

The response for querying alert rules.

Examples

Success response

JSON format

{
  "code": "200",
  "data": {
    "alertRules": [
      {
        "actionIntegrationConfig": {
          "actions": [
            "xxxx-xxxx-xxxx"
          ],
          "enabled": false
        },
        "annotations": {
          "key": "{'platform': 'github'}\n"
        },
        "armsIntegrationConfig": {
          "enabled": true
        },
        "bizSource": "Sample value",
        "conditionConfig": {
          "type": "PROMETHEUS_SIMPLE_CONDITION",
          "durationSecs": 60,
          "severity": "INFO",
          "operator": "GT",
          "threshold": 30,
          "min": 1,
          "max": 1,
          "aggregate": "AVG",
          "matchField": "Example value",
          "matchOperator": "PRESENT",
          "matchValue": "Example value",
          "countOperator": "GTE",
          "countThreshold": 100,
          "thresholdList": [
            {
              "max": 100,
              "min": 0,
              "severity": "CRITICAL",
              "threshold": 80
            }
          ],
          "compareList": [
            {
              "absDeviation": 0,
              "aggregate": "AVG",
              "baselinePeriod": "AUTO",
              "operator": "OUT_OF_BAND",
              "sensitivity": "MEDIUM",
              "threshold": 100,
              "yoyTimeUnit": "day",
              "yoyTimeValue": 1
            }
          ],
          "relation": "AND",
          "escalationType": "SIMPLE",
          "simpleEscalation": {
            "escalations": [
              {
                "absDeviation": 0,
                "baselinePeriod": "AUTO",
                "comparisonOperator": "GT",
                "preCondition": "3 consecutive times",
                "sensitivity": "MEDIUM",
                "severity": "CRITICAL",
                "statistics": "Average",
                "threshold": "80",
                "times": 3
              }
            ],
            "metricName": "cpuUsage",
            "period": 60
          },
          "compositeEscalation": {
            "escalations": [
              {
                "absDeviation": 0,
                "baselinePeriod": "AUTO",
                "comparisonOperator": "GT",
                "metricName": "cpuUsage",
                "period": 60,
                "preCondition": "3 consecutive times",
                "sensitivity": "MEDIUM",
                "statistics": "Average",
                "threshold": "80"
              }
            ],
            "relation": "AND",
            "severity": "CRITICAL",
            "times": 3
          },
          "expressEscalation": {
            "rawExpression": "cpu_usage > 90",
            "severity": "CRITICAL",
            "times": 3
          },
          "prometheus": {
            "promQl": "rate(http_errors_total[5m]) > 0.1",
            "severity": "CRITICAL",
            "times": 3
          },
          "triggers": [
            {
              "comparisonOperator": "SampleValue",
              "condition": "SampleValue",
              "conditions": [
                {
                  "absDeviation": 0,
                  "baselinePeriod": "AUTO",
                  "expressionType": "SIMPLE",
                  "max": 100,
                  "min": 0,
                  "operator": "GT",
                  "queryName": "cpuQuery",
                  "sensitivity": "MEDIUM",
                  "threshold": 80
                }
              ],
              "countCondition": "SampleValue",
              "countOperator": "GTE",
              "countThreshold": 100,
              "durationSecs": 1,
              "expressionType": "default",
              "logicOperator": "AND",
              "matchField": "SampleValue",
              "matchOperator": "PRESENT",
              "matchValue": "SampleValue",
              "max": 1,
              "metricName": "SampleMetricName",
              "min": 1,
              "operator": "GT",
              "period": 1,
              "preCondition": "SampleValue",
              "queryName": "SampleMetricName",
              "severity": "INFO",
              "statistics": "SampleValue",
              "threshold": "90",
              "times": 1
            }
          ],
          "noDataPolicy": "Example value",
          "noDataAlertSeverity": "INFO",
          "noDataAlertLevel": "INFO",
          "noDataAppendValue": 1,
          "noDataDurationSecs": 600,
          "alertCount": 1,
          "legacyType": "default",
          "yoyTimeUnit": "minute",
          "yoyTimeValue": 1,
          "sensitivity": "MEDIUM",
          "absDeviation": 0,
          "baselinePeriod": "AUTO",
          "enableSeveritySuppression": true,
          "legacyRaw": "Example value"
        },
        "contentTemplate": "Alert triggered: the current value ${currentValue} of ${metricName} exceeds the threshold ${threshold}",
        "createdAt": "1751595283143",
        "datasourceConfig": {
          "instanceId": "rw-xxx",
          "legacyRaw": "{\"type\":\"SLS\"}",
          "legacyType": "SLS",
          "namespace": "selectdb",
          "productCategory": "ecs",
          "project": "my-project",
          "regionId": "cn-hangzhou",
          "stores": [
            {
              "project": "my-sls-project",
              "regionId": "cn-hangzhou",
              "store": "my-log-store",
              "storeType": "LOG"
            }
          ],
          "tenantId": "t-xxxxxxx",
          "type": "PROMETHEUS"
        },
        "datasourceType": "default",
        "displayName": "CPU usage alert: 95%",
        "enabled": true,
        "labels": {
          "key": "{'platform': 'github'}"
        },
        "managedBy": "integrationCenter",
        "notifyConfig": {
          "activeDays": [
            1
          ],
          "activeEndTime": "20:00",
          "activeStartTime": "08:00",
          "channels": [
            {
              "identifiers": [
                "TEST"
              ],
              "type": "CONTACT"
            }
          ],
          "notifyStrategies": [
            "example-id-001"
          ],
          "sendRecoverNotification": true,
          "severityChannels": {
            "key": {
              "receivers": [
                {
                  "targetType": "CONTACT",
                  "identifiers": [
                    "TEST"
                  ],
                  "channels": [
                    "SMS"
                  ]
                }
              ],
              "sendRecoverNotification": true
            }
          },
          "silenceTimeSecs": 60,
          "type": "DIRECT_NOTIFY",
          "utcOffset": "+08:00"
        },
        "notifyStrategyId": "example-id-001",
        "observeResourceConfig": {
          "entityDomain": "cloud_monitor",
          "entityType": "ACS::ECS::Instance",
          "namespace": "acs_ecs_dashboard",
          "productCategory": "ecs",
          "relationType": "ALL",
          "resources": [
            "env=prod"
          ]
        },
        "observeResourceGlobalScope": true,
        "observeResourceList": [
          "i-bp1abcxxxxxxxx"
        ],
        "observeResourceType": "default",
        "partitionKey": "Sample value",
        "queryConfig": {
          "aggregate": "AVG",
          "checkAfterDataComplete": true,
          "dimensions": [
            {
              "key": "i-abc123"
            }
          ],
          "durationSecs": 100,
          "enableDataCompleteCheck": true,
          "entityDomain": "k8s",
          "entityFields": [
            {
              "field": "region",
              "value": "cn-hangzhou"
            }
          ],
          "entityFilters": [
            {
              "field": "region",
              "operator": "=",
              "value": "cn-hangzhou"
            }
          ],
          "entityType": "k8s.pod",
          "expr": "Sample value",
          "filterList": [
            {
              "key": "env",
              "type": "ALL",
              "value": "prod"
            }
          ],
          "filterValues": [
            {
              "dim": "host",
              "opt": "=",
              "value": "web-01"
            }
          ],
          "groupFieldList": [
            "hostName"
          ],
          "groupId": "og-845e0a26455f437c",
          "groupType": "default",
          "joinings": [
            {
              "conditions": [
                {
                  "lhsField": "request_id",
                  "operator": "=",
                  "rhsField": "trace_id"
                }
              ],
              "type": "INNER"
            }
          ],
          "labelFilters": [
            {
              "name": "env",
              "operator": "=",
              "value": "prod"
            }
          ],
          "legacyRaw": "Sample value",
          "legacyType": "default",
          "logSet": "Sample name",
          "measureGroupKey": "Sample value",
          "measureList": [
            {
              "groupBy": [
                "host.name"
              ],
              "measureCode": "cpu_usage",
              "windowSecs": 60
            }
          ],
          "metric": "node_cpu_seconds_total",
          "metricGroupId": "example-id-001",
          "metricId": "example-id-001",
          "metricIds": [
            "upper_normal"
          ],
          "metricSet": "cms.acs_ecs_dashboard.CPUUtilization",
          "namespace": "Sample name",
          "offsetSecs": 100,
          "paramValues": [
            {
              "name": "threshold",
              "value": "80"
            }
          ],
          "promQl": "avg(rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100",
          "queries": [
            {
              "end": 100,
              "expr": "Sample value",
              "labelFilters": [
                {
                  "name": "env",
                  "operator": "=",
                  "value": "prod"
                }
              ],
              "metric": "Sample name",
              "metricSet": "Sample name",
              "name": "Sample name",
              "start": 100,
              "timeUnit": "second",
              "window": 100
            }
          ],
          "relationType": "INSTANCE",
          "serviceIdList": [
            "xxx-xxx-xxx"
          ],
          "type": "PROMETHEUS_SINGLE_QUERY",
          "windowSecs": 100
        },
        "rcaConfig": {
          "enableRca": false,
          "digitalEmployeeName": "O&M Assistant"
        },
        "regionId": "example-id-001",
        "scheduleConfig": {
          "intervalSecs": 30,
          "type": "FIXED"
        },
        "severityLevels": "1",
        "status": "Alarm",
        "updatedAt": "1764556086388",
        "uuid": "xxxxx-xxxx-xxxx",
        "workspace": "workspace-test"
      }
    ],
    "totalCount": 5
  },
  "message": "The request is invalid.",
  "nextToken": "caeba0bbb2be03f84eb48b699f0a4883",
  "pageNumber": 1,
  "pageSize": 100,
  "requestId": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890",
  "success": true,
  "total": 1
}

Error codes

HTTP status code

Error code

Error message

Description

400 IdempotentParameterMismatch The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.
400 InvalidParameter %s is missing or invalid. The parameter %s is missing or invalid.
400 ParameterInvalid The parameter is missing or invalid. %s The parameter is missing or invalid.
500 InternalUnknownError The request processing has failed due to some unknown error. A service runtime error occurred.
403 Forbidden You are not authorized to operate the specified resource. No permission, please use RAM to authorize
404 ResourceNotFound The specified resource is not found. The specified resource is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.