Updated on 2025-10-24 GMT+08:00

Handling Alarms

Function

This API is used to select a contingency plan, script, or job to handle an alarm. You can select an alarm by the alarm ID. You need to specify the contingency plan, script, or job to be executed. For details, see the request parameter description and request example.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    coc:instance:executeDocument

    Write

    instance *

    -

    -

    -

    document *

    -

    -

    • coc:ApplicationId

    • coc:ApplicationGroupId

    • g:EnterpriseProjectId

    • coc:DocumentRiskLevel

URI

POST /v1/alarm-mgmt/alarm/{alarm_id}/auto-process

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

alarm_id

Yes

String

Definition:

Alarm ID, which uniquely identifies an alarm. You can obtain the alarm ID from the aggregated alarms page of the alarm management module on COC.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

task_type

Yes

Object

Definition:

Task type. A specific task needs to be executed to handle alarms. For details, see the value range.

Constraints:

N/A

Value range:

  • PLAN: contingency plan

  • SCRIPT: script

  • RUNBOOK: job

Default value:

N/A

associated_task_id

Yes

String

Definition:

Unique ID of a task.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

associated_task_type

Yes

Object

Definition:

Task type. Each task can be classified as a custom task or a public task.

Constraints:

N/A

Value range:

  • CUSTOMIZATION: custom task.

  • COMMUNAL: public task.

Default value:

N/A

associated_task_name

Yes

String

Definition:

Task name.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

associated_task_enterprise_project_id

No

String

Definition:

Enterprise project ID. Enterprise ID created by a user on EPS.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

runbook_instance_mode

No

Object

Definition:

Job instance mode.

Constraints:

Select the target instance mode after selecting the job inAlarm Management.

Value range:
  • SAME: The steps are the same.

  • DIFF: The steps are independent.

  • MIXED: The steps are customized.

Default value:

SAME

input_param

Yes

Map<String,String>

Definition:

Task execution parameter.

Constraints:

Select the target instance mode after selecting the job inAlarm Management.

Value range:

0–1,000 characters, in JSON format.

Default value:

N/A

target_instances

No

Array of ScheduleInstance objects

Definition:

Target instance information.

Constraints:

Select the target instance after selecting the job inAlarm Management.

Value range:

N/A

Default value:

N/A

region_id

No

String

Definition:

Region ID.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 3 ScheduleInstance

Parameter

Mandatory

Type

Description

target_selection

Yes

String

Definition:

Target selection mode.

Constraints:

Select the instance selection mode on the alarm handling page in Alarm Management](tag:hws_hk).

Value range:

  • ALL: Select all instances automatically.

  • MANUAL: Select instances manually.

  • NONE: Select no instance.

Default value:

MANUAL

order_no

Yes

Integer

Definition:

Step sequence number.

Constraints:

Select the job step number (starting from 0) on the alarm handling page in Alarm Management](tag:hws_hk).

Value range:

N/A

Default value:

N/A

batch_strategy

No

String

Definition:

Batch policy. You can select a batch policy to control the execution scale of instances.

Constraints:

Select the batch policy on the alarm handling page in Alarm Management](tag:hws_hk).

Value range:

  • AUTO_BATCH: automatic batching

  • MANUAL_BATCH: manual batching

  • NONE: no batching

Default value:

N/A

sub_target_instances

No

Array of ScheduleInstance objects

Definition:

Sub-step instance target. You can execute some instances in the sub-steps of a task.

Constraints:

The number of sub-step instance targets cannot exceed 10,000.

Value range:

N/A

Default value:

N/A

Response Parameters

Status code: 200

Response is returned correctly.

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

Example Requests

  • Use a contingency plan to handle the alarm whose ID is ALM2025071417361705s6mUUrF.

    POST https://{Endpoint}/v1/alarm-mgmt/alarm/ALM2025071417361705s6mUUrF/auto-process
    
    {
      "task_type" : "PLAN",
      "associated_task_type" : "CUSTOMIZATION",
      "associated_task_id" : "CTP20250705005804610013656",
      "associated_task_enterprise_project_id" : "0",
      "associated_task_name" : "test-v5",
      "input_param" : {
        "success_rate" : 100,
        "timeout" : 300,
        "execute_user" : "root",
        "project_id" : "****",
        "script_params" : "[{\"paramName\":\"aaa\",\"paramValue\":\"1\",\"paramOrder\":1}]"
      },
      "target_instances" : [ {
        "target_selection" : "MANUAL",
        "target_instances" : "{\"batches\":[{\"batchIndex\":1,\"rotationStrategy\":\"CONTINUE\",\"targetInstances\":[{\"resourceId\":\"****\",\"regionId\":\"***\",\"provider\":\"ECS\",\"type\":\"CLOUDSERVERS\",\"agentSn\":\"****\",\"agentStatus\":\"ONLINE\",\"nodeId\":\"\",\"enterpriseProjectId\":\"0\",\"properties\":{\"hostName\":\"platform04-l60076595\",\"fixedIp\":\"192.168.0.50\",\"regionId\":\"***\",\"zoneId\":\"***a\",\"projectId\":\"****\"}}],\"cmdbInstances\":[{\"id\":\"****\",\"resourceId\":\"****\",\"name\":\"platform04-l60076595\",\"projectId\":\"****\",\"domainId\":\"****\",\"regionId\":\"***\",\"agentId\":\"****\",\"agentState\":\"ONLINE\",\"provider\":\"ecs\",\"enterpriseProjectId\":\"0\",\"type\":\"cloudservers\",\"properties\":{\"addresses\":[{\"OsExtIpsType\":\"fixed\",\"OsExtIpsPortId\":\"055f2d75-f3fc-439a-8958-e7bc0b75cb9f\",\"addr\":\"192.168.0.50\",\"version\":4,\"OsExtIpsMacAddr\":\"fa:16:3e:fa:52:84\",\"primary\":true}],\"metadata\":{\"osType\":\"Linux\"},\"OsExtAz\":\"***a\",\"status\":\"SHUTOFF\"}}]}],\"policy\":\"none\",\"all_rotation\":\"FIRST_PAUSE\"}",
        "order_no" : 0,
        "batch_strategy" : "NONE"
      } ],
      "runbook_instance_mode" : "SAME",
      "sub_task_info" : {
        "sub_task_type" : "SCRIPT",
        "sub_associated_task_id" : "SC202507042240130195716f7",
        "sub_associated_task_name" : "yy-ccc",
        "sub_associated_task_type" : "CUSTOMIZATION"
      }
    }
  • Use a script to handle the alarm whose ID is ALM2025071417361705s6mUUrF.

    POST https://{Endpoint}/v1/alarm-mgmt/alarm/ALM2025071417361705s6mUUrF/auto-process
    
    {
      "task_type" : "SCRIPT",
      "associated_task_type" : "CUSTOMIZATION",
      "associated_task_id" : "SC2025071006154101b779eb7",
      "associated_task_enterprise_project_id" : "0",
      "associated_task_name" : "testScript92DDf",
      "input_param" : {
        "timeout" : 300,
        "execute_user" : "root",
        "success_rate" : 100,
        "project_id" : "****",
        "script_params" : "[]"
      },
      "target_instances" : [ {
        "target_selection" : "MANUAL",
        "target_instances" : "{\"batches\":[{\"batchIndex\":1,\"rotationStrategy\":\"CONTINUE\",\"targetInstances\":[{\"resourceId\":\"****\",\"regionId\":\"***\",\"provider\":\"ECS\",\"type\":\"CLOUDSERVERS\",\"agentSn\":\"****\",\"agentStatus\":\"ONLINE\",\"nodeId\":\"\",\"enterpriseProjectId\":\"0\",\"properties\":{\"hostName\":\"platform04-l60076595\",\"fixedIp\":\"192.168.0.50\",\"regionId\":\"***\",\"zoneId\":\"***a\",\"projectId\":\"****\"}}],\"cmdbInstances\":[{\"id\":\"****\",\"resourceId\":\"****\",\"name\":\"platform04-l60076595\",\"projectId\":\"****\",\"domainId\":\"****\",\"regionId\":\"***\",\"agentId\":\"****\",\"agentState\":\"ONLINE\",\"provider\":\"ecs\",\"enterpriseProjectId\":\"0\",\"type\":\"cloudservers\",\"properties\":{\"addresses\":[{\"OsExtIpsType\":\"fixed\",\"OsExtIpsPortId\":\"055f2d75-f3fc-439a-8958-e7bc0b75cb9f\",\"addr\":\"192.168.0.50\",\"version\":4,\"OsExtIpsMacAddr\":\"fa:16:3e:fa:52:84\",\"primary\":true}],\"metadata\":{\"osType\":\"Linux\"},\"OsExtAz\":\"***a\",\"status\":\"ACTIVE\"}}]}],\"policy\":\"none\",\"all_rotation\":\"FIRST_PAUSE\"}",
        "order_no" : 0,
        "batch_strategy" : "NONE"
      } ],
      "runbook_instance_mode" : "SAME",
      "sub_task_info" : null
    }
  • Use a job to process the alarm whose ID is ALM2025071417361705s6mUUrF.

    POST https://{Endpoint}/v1/alarm-mgmt/alarm/ALM2025071417361705s6mUUrF/auto-process
    
    {
      "task_type" : "RUNBOOK",
      "associated_task_type" : "CUSTOMIZATION",
      "associated_task_id" : "RB2025070814434301497f304",
      "associated_task_enterprise_project_id" : "0",
      "associated_task_name" : "listinstance",
      "associated_task_name_en" : "",
      "input_param" : {
        "success_rate" : 100,
        "project_id" : "****",
        "job_uuid" : "RB2025070814434301497f304",
        "execute_atomic_tasks" : "[{\"accountmgmt_changepwd_task\":false,\"task_name\":\"listinstance\",\"task_name_en\":null,\"task_desc\":null,\"task_desc_en\":null,\"atomic_unique_key\":\"execute_api\",\"type\":\"Simple\",\"sub_tasks\":[{\"accountmgmt_changepwd_task\":false,\"task_name\":\"listinstance\",\"task_name_en\":null,\"task_desc\":null,\"task_desc_en\":null,\"atomic_unique_key\":\"execute_api\",\"type\":\"Simple\",\"sub_tasks\":[],\"inputs\":[{\"param_key\":\"service\",\"param_value\":\"Kafka\",\"value_type\":\"CUSTOM\",\"atomic_name\":null},{\"param_key\":\"apiName\",\"param_value\":\"ListInstances\",\"value_type\":\"CUSTOM\",\"atomic_name\":null},{\"param_key\":\"path\",\"param_value\":{},\"value_type\":\"COMPLEX\",\"atomic_name\":null},{\"param_key\":\"query\",\"param_value\":{\"engine\":\"kafka\",\"name\":null,\"instance_id\":\"****\",\"status\":null,\"include_failure\":null,\"exact_match_name\":null,\"enterprise_project_id\":null,\"offset\":null,\"limit\":null},\"value_type\":\"COMPLEX\",\"atomic_name\":null},{\"param_key\":\"body\",\"param_value\":{},\"value_type\":\"COMPLEX\",\"atomic_name\":null}],\"outputs\":[],\"display_region\":\"REQUIRED\",\"error_handle_type\":\"STOP\",\"execute_batches\":[],\"loop_instances\":[],\"target_instance\":{\"limit\":999,\"required\":false},\"loop_item\":null,\"label\":\"1. listinstance\",\"default_filter_params\":{\"agent_state\":\"ONLINE\"},\"checked_instance\":[]}],\"inputs\":[{\"param_key\":\"service\",\"param_value\":\"Kafka\",\"value_type\":\"CUSTOM\",\"atomic_name\":null},{\"param_key\":\"apiName\",\"param_value\":\"ListInstances\",\"value_type\":\"CUSTOM\",\"atomic_name\":null},{\"param_key\":\"path\",\"param_value\":{},\"value_type\":\"COMPLEX\",\"atomic_name\":null},{\"param_key\":\"query\",\"param_value\":{\"engine\":\"kafka\",\"name\":null,\"instance_id\":\"****\",\"status\":null,\"include_failure\":null,\"exact_match_name\":null,\"enterprise_project_id\":null,\"offset\":null,\"limit\":null},\"value_type\":\"COMPLEX\",\"atomic_name\":null},{\"param_key\":\"body\",\"param_value\":{},\"value_type\":\"COMPLEX\",\"atomic_name\":null}],\"outputs\":[],\"display_region\":\"REQUIRED\",\"error_handle_type\":\"STOP\",\"execute_batches\":[],\"loop_instances\":[],\"target_instance\":{\"limit\":999,\"required\":false},\"loop_item\":null,\"label\":\"1. listinstance\",\"step_same_active\":true,\"step_diff_active\":true}]",
        "vars" : "[]"
      },
      "target_instances" : [ {
        "target_selection" : "NONE",
        "target_resource" : null,
        "order_no" : 0,
        "batch_strategy" : null,
        "sub_target_instances" : [ {
          "target_selection" : "NONE",
          "target_resource" : null,
          "target_instances" : null,
          "order_no" : 0,
          "batch_strategy" : null
        } ]
      } ],
      "runbook_instance_mode" : "DIFF",
      "instance_required" : false,
      "sub_task_info" : null,
      "region_id" : "***"
    }

Example Responses

Status code: 200

Response is returned correctly.

{
  "errorCode" : "200",
  "errorMsg" : "Success",
  "data" : "RBT2025071417373701226d25c"
}

Status Codes

Status Code

Description

200

Response is returned correctly.

400

Invalid request from the client.

Error Codes

See Error Codes.