Help Center/ Application Operations Management/ API Reference (Ally Region)/ APIs/ Alarm/ Updating Prometheus Alarm Rules in Batches
Updated on 2026-01-06 GMT+08:00

Updating Prometheus Alarm Rules in Batches

Function

This API is used to enable or disable Prometheus alarm rules in batches and change their action rules in batches.

Calling Method

For details, see Calling APIs.

URI

PUT /v4/{project_id}/alarm-rules/batch-update

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID, which can be obtained from the console or by calling an API. For details, see Obtaining a Project ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

action

Yes

String

Batch operations:

  • enable: Enable Prometheus alarm rules in batches.

  • disable: Disable Prometheus alarm rules in batches.

  • BATCH_UPDATE_ACTION_RULE: Change the action rules of Prometheus alarm rules in batches.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details, see Obtaining a Token.

Content-Type

Yes

String

Message body type or format, which is application/json.

Enterprise-Project-Id

No

String

Enterprise project ID. For details, see Obtaining an Enterprise Project ID.

  • To enable, disable, or modify instances in an enterprise project in batches, specify a desired enterprise project ID.

  • If this parameter is left blank, instances in the default enterprise project are enabled, disabled, or modified in batches. The default enterprise project ID is 0.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

alarm_rules

No

Array of BatchAlarmRulesBody objects

Alarm rules to be enabled or disabled in batches. This parameter is mandatory when you need to enable or disable alarm rules in batches.

update_action_rules

No

Array of BatchUpdateActionRules objects

Alarm rules whose action rules are to be modified in batches. This parameter is mandatory when you need to modify alarm action rules in batches.

update_type

No

String

Update type. Option: BATCH_UPDATE_ACTION_RULE. This parameter is mandatory when you need to modify alarm action rules in batches.

Table 5 BatchAlarmRulesBody

Parameter

Mandatory

Type

Description

alarm_rule_enable

Yes

Boolean

Whether the alarm rule is enabled.

alarm_rule_id

Yes

Long

Alarm rule ID.

alarm_rule_name

Yes

String

Alarm rule name.

alarm_rule_type

Yes

String

Alarm rule type.

  • metric: Prometheus metric rule.

  • event: Event rule.

Table 6 BatchUpdateActionRules

Parameter

Mandatory

Type

Description

alarm_rule_id

Yes

Long

Alarm rule ID.

alarm_rule_name

Yes

String

Alarm rule name.

alarm_rule_type

Yes

String

Alarm rule type.

bind_notification_rule_id

No

String

Name of the alarm action rule to be bound.

frequency

Yes

String

Notification frequency.

  • If the notification type is alarm_policy, set this parameter to -1.

  • If the notification type is direct, set this parameter to any of the following:

  • 0: alarm sent only once

  • 300: every 5 minutes

  • 600: every 10 minutes

  • 900: every 15 minutes

  • 1800: every 30 minutes

  • 3600: every hour

  • 10800: every 3 hours

  • 21600: every 6 hours

  • 43200: every 12 hours

  • 86400: every day

notification_enable

No

Boolean

Whether to enable the alarm notification rule.

  • If the notification type is direct, set this parameter to true.

  • If the notification type is alarm_policy, set this parameter to false.

If both notify_triggered and notify_resolved are set to false, notification_enable must be set to false.

notification_type

No

String

Notification type.

  • direct: direct alarm reporting

  • alarm_policy: alarm reporting after noise reduction

notify_resolved

Yes

Boolean

Whether to send a notification when an alarm is cleared.

  • true: Send a notification.

  • false: Do not send any notification.

notify_triggered

Yes

Boolean

Whether to send a notification when an alarm is triggered.

  • true: Send a notification.

  • false: Do not send any notification.

route_group_enable

No

Boolean

Whether to enable a grouping rule.

  • If the notification type is alarm_policy, set this parameter to true.

  • If the notification type is direct, set this parameter to false.

If both notify_triggered and notify_resolved are set to false, route_group_enable must be set to false.

route_group_rule

No

String

Grouping rule name.

  • If route_group_enable is set to true, enter a grouping rule name.

  • If route_group_enable is set to false, enter "".

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_message

String

Error message.

resources

Array of BatchUpdateItemResult objects

Resources.

Table 8 BatchUpdateItemResult

Parameter

Type

Description

resource_alias

String

Resource alias.

resource_name

String

Resource name.

ret_status

String

Resource update status.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

error_type

String

Error type.

trace_id

String

Request ID.

Example Requests

  • Enable alarm rules in batches.

    https://{Endpoint}/v4/{project_id}/alarm-rules/batch-update?action=enable
    
    {
      "alarm_rules" : [ {
        "alarm_rule_enable" : false,
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0002",
        "alarm_rule_type" : "metric"
      }, {
        "alarm_rule_enable" : false,
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0003",
        "alarm_rule_type" : "metric"
      } ]
    }
  • Disable alarm rules in batches.

    https://{Endpoint}/v4/{project_id}/alarm-rules/batch-update?action=disable
    
    {
      "alarm_rules" : [ {
        "alarm_rule_enable" : true,
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0002",
        "alarm_rule_type" : "metric"
      }, {
        "alarm_rule_enable" : true,
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0003",
        "alarm_rule_type" : "metric"
      } ]
    }
  • Change the alarm mode of alarm rules to "Direct alarm reporting" in batches.

    https://{Endpoint}/v4/{project_id}/alarm-rules/batch-update?action=BATCH_UPDATE_ACTION_RULE
    
    {
      "update_action_rules" : [ {
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0002",
        "alarm_rule_type" : "metric",
        "bind_notification_rule_id" : "111111111111111111111111111111111111111111111111111111111111111111",
        "frequency" : "0",
        "notification_enable" : true,
        "notification_type" : "direct",
        "notify_resolved" : true,
        "notify_triggered" : true
      }, {
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0003",
        "alarm_rule_type" : "metric",
        "bind_notification_rule_id" : "111111111111111111111111111111111111111111111111111111111111111111",
        "frequency" : "0",
        "notification_enable" : true,
        "notification_type" : "direct",
        "notify_resolved" : true,
        "notify_triggered" : true
      } ],
      "update_type" : "BATCH_UPDATE_ACTION_RULE"
    }
  • Change the alarm mode of alarm rules to "Alarm noise reduction" in batches.

    https://{Endpoint}/v4/{project_id}/alarm-rules/batch-update?action=BATCH_UPDATE_ACTION_RULE
    
    {
      "update_action_rules" : [ {
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0002",
        "alarm_rule_type" : "metric",
        "frequency" : "0",
        "notification_type" : "alarm_policy",
        "notify_resolved" : true,
        "notify_triggered" : true,
        "route_group_enable" : true,
        "route_group_rule" : "aom1"
      }, {
        "alarm_rule_id" : 1366,
        "alarm_rule_name" : "0003",
        "alarm_rule_type" : "metric",
        "frequency" : "0",
        "notification_type" : "alarm_policy",
        "notify_resolved" : true,
        "notify_triggered" : true,
        "route_group_enable" : true,
        "route_group_rule" : "aom1"
      } ],
      "update_type" : "BATCH_UPDATE_ACTION_RULE"
    }

Example Responses

Status code: 200

OK: The request is successful. When alarm rules are enabled or disabled in batches, "null" is returned. When alarm rules are modified in batches, the following information is returned:

{
  "error_code" : "200",
  "error_message" : "success",
  "resources" : [ {
    "resource_alias" : "0002",
    "resource_name" : "0002",
    "ret_status" : "Success"
  }, {
    "resource_alias" : "0003",
    "resource_name" : "0003",
    "ret_status" : "Success"
  } ]
}

Status code: 400

Bad Request: Invalid request. The client should not repeat this request without modification.

{
  "error_code" : "AOM.02025026",
  "error_msg" : "Input alarmParams  is invalid: rule name or type is empty",
  "error_type" : "BAD_REQUEST",
  "trace_id" : "ff96d66927d839a49fb93d7ccaab3dae"
}

Status Codes

Status Code

Description

200

OK: The request is successful. When alarm rules are enabled or disabled in batches, "null" is returned. When alarm rules are modified in batches, the following information is returned:

400

Bad Request: Invalid request. The client should not repeat this request without modification.

Error Codes

See Error Codes.