ManageAlertRules

Updated at:

Manages 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

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:ManageAlertRules

none

*All Resource

*

None None

Request syntax

POST /manageAlertRules HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

callSource

string

No

The call source identifier. It identifies the internal integration channel to which the caller belongs, such as bailian, integrationCenter, or managed_service_for_prometheus, and is used to isolate traffic from different sources. You do not need to specify this parameter for standard OpenAPI calls.

bailian

DryRun

boolean

No

Specifies whether to perform a dry run. If you set this parameter to true, the system only validates the request and returns the validation result in dryRunResult without writing data to the database or triggering side effects such as template synchronization. Default value: false.

body ManageAlertRulesUnifiedActionInput

No

The request body for managing alert rules. This body is shared by the CREATE, UPDATE, PATCH, and BATCH_DELETE operations. Specify the fields based on the action.

Response elements

Element

Type

Description

Example

ServerResponseManageAlertRulesResult

The server response for managing alert rules.

Examples

Success response

JSON format

{
  "code": "200",
  "data": {
    "alertRule": {
      "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"
    },
    "deletedCount": 1,
    "deletedUuidList": [
      "xxx-xxx-xxx"
    ],
    "drillUuid": "7c27ee14-5f94-469f-912d-476f79c8a861",
    "dryRunResult": {
      "exitCode": 1,
      "result": "rejected",
      "violations": [
        {
          "field": "schedule.intervalSecs",
          "message": "schedule interval must be a multiple of 15 seconds",
          "suggestion": "must satisfy: 15-86400 seconds and a multiple of 15"
        }
      ]
    },
    "updatedCount": 1,
    "updatedUuidList": [
      "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
    ]
  },
  "message": "The specified alert rule UUID does not exist.",
  "nextToken": "caeba0bbb2be03f84eb48b699f0a4883",
  "pageNumber": 1,
  "pageSize": 10,
  "requestId": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890",
  "success": true,
  "total": 8
}

Error codes

HTTP status code

Error code

Error message

Description

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.