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
|
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. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
action |
Yes |
String |
Batch operations:
|
Request 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.
|
|
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. |
|
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.
|
|
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.
|
|
notification_enable |
No |
Boolean |
Whether to enable the alarm notification rule.
If both notify_triggered and notify_resolved are set to false, notification_enable must be set to false. |
|
notification_type |
No |
String |
Notification type.
|
|
notify_resolved |
Yes |
Boolean |
Whether to send a notification when an alarm is cleared.
|
|
notify_triggered |
Yes |
Boolean |
Whether to send a notification when an alarm is triggered.
|
|
route_group_enable |
No |
Boolean |
Whether to enable a grouping rule.
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.
|
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code. |
|
error_message |
String |
Error message. |
|
resources |
Array of BatchUpdateItemResult objects |
Resources. |
|
Parameter |
Type |
Description |
|---|---|---|
|
resource_alias |
String |
Resource alias. |
|
resource_name |
String |
Resource name. |
|
ret_status |
String |
Resource update status. |
Status code: 400
|
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot