Obtaining the Alarm Sending Result
Function
This API is used to obtain the alarm sending result.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/alarm-notified-histories
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
event_sn |
No |
String |
Alarm serial number. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. |
Content-Type |
Yes |
String |
Content type, which is application/json. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
notified_histories |
Array of NotifiedHistoriesResult objects |
Historical notification list. |
Parameter |
Type |
Description |
---|---|---|
event_sn |
String |
Alarm serial number. |
notifications |
Array of Notifications objects |
Notification result. |
Parameter |
Type |
Description |
---|---|---|
action_rule |
String |
Alarm action rule name. |
notifier_channel |
String |
Notification type. SMN: Simple Message Notification. |
smn_channel |
SmnResponse object |
Notification result details. |
Parameter |
Type |
Description |
---|---|---|
sent_time |
Long |
Sending time. |
smn_notified_history |
Array of SmnInfo objects |
Content of a notification. |
smn_request_id |
String |
ID for requesting SMN. |
smn_response_body |
String |
Information returned after the SMN service is invoked. |
smn_response_code |
String |
HTTP status code returned after the SMN service is invoked. |
smn_topic |
String |
SMN topic. |
Parameter |
Type |
Description |
---|---|---|
smn_notified_content |
String |
SMN message content. |
smn_subscription_status |
Integer |
SMN subscription status. |
smn_subscription_type |
String |
SMN subscription type. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
error_type |
String |
Error type. |
trace_id |
String |
Request ID. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
error_type |
String |
Error type. |
trace_id |
String |
Request ID. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. |
error_msg |
String |
Response message. |
trace_id |
String |
Response ID. |
Example Requests
Obtain the sending result of the alarm whose serial number is 1044686593798963201.
https://{Endpoint}/v2/{project_id}/alarm-notified-histories?event_sn=1044686593798963201
Example Responses
Status code: 200
OK: The request is successful.
{ "notified_histories" : [ { "event_sn" : "1044686593798963201", "notifications" : [ { "action_rule" : "lhy_alarm_action_test01", "notifier_channel" : "SMN", "smn_channel" : { "sent_time" : 1669114269797, "smn_notified_history" : [ { "smn_notified_content" : "<style> span { display: inline-block; float: left; font-size: 14px; } b { display: inline-block; float: left; color: #252B3A; font-size: 14px }</style><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"font-family:HuaweiFont,Helvetica,Arial,PingFangSC-Regular,Hiragino Sans GB,Microsoft YaHei,Microsoft JhengHei;border-spacing:0px 14px;font-size:14px;padding-left: 30px;line-height:25px;\"> <thead> <tr style=\"font-size:14px;\"> <td colspan=\"2\" style=\"line-height:28px;color:#6e6e6e;font-size:14px\"> <b>Dear </b> <b>users</b> <b> </b> </td> </tr> </thead> <tr> <td colspan=\"2\"> <span>1 notification has been </span> <b>generated</b> <span> in region ***</span> <b> based on action rule lhy_alarm_action_test01.</b> <span></span> <span></span> <span><span>The alarm rule is </span><b>lhy_test_001</b></span> <span>. For more information, go to the AOM console.</span> <br> <br> </td> </tr> <tr style=\"font-size:14px;\"> <td colspan=\"2\"> <p style=\"margin-bottom: -20px; margin-top: -26px;\"> <span style=\"color:#252B3A;line-height:24px\">Here are the details.</span> </p> </td> </tr> <td><div>Account: kaifatest;<br>Notification Type: alarm;<br>CAS Application Name: app-1;<br>Notification Type: NA;<br>Severity: Critical;<br>Name: lhy_test_001;<br>Occurred: 2022-11-22 18:51:05 GMT+08:00;<br>Source: AOM;<br>Resource Type: Application;<br>Resource Identifier: <br> casApplicationID: 2d216a2b-9a58-452e-9a82-fc0c7cbcd322;<br> casApplicationName: app-1;<br>Possible Cause: If the specified metric value crosses the threshold and the alarm severity is \\\"critical\\\", an alarm is triggered.;<br>Link: https://console.xxx/aom/alarmlist;<br>Additional Info: The threshold rule lhy_test_001 status changes from \\\"init\\\" to \\\"alarm\\\". The value of \\\"cpuCoreLimit\\\" is \\\"0.250\\\" and meets the threshold criterion \\\">=0\\\"<br>Suggestion: NA;<br><div/></td> </table>", "smn_subscription_status" : 1, "smn_subscription_type" : "email" }, { "smn_notified_content" : "[AOM][Critical_alarm_generated] \nAlert Name: lhy_test_001;\nCAS Application Name: app-1;\nOccurrence Time: 2022-11-22 18:51:05 GMT+08:00;\nLink: https://console.xxx/aom/alarmlist;\nAlert Content: The threshold rule lhy_test_001 status changes from \"init\" to \"alarm\". The value of \"cpuCoreLimit\" is \"0.250\" and meets the threshold criterion \">=0\".;\nThis message is configured in an AOM alarm rule by kaifatest. For more information, go to the AOM console.\",", "smn_subscription_status" : 0, "smn_subscription_type" : "sms" }, { "smn_notified_content" : "[AOM][Critical_alarm_generated] \nAlert Name: lhy_test_001;\nCAS Application Name: app-1;\nOccurrence Time: 2022-11-22 18:51:05 GMT+08:00;\nLink: https://console.xxx/aom/alarmlist;\nAlert Content: The threshold rule lhy_test_001 status changes from \"init\" to \"alarm\". The value of \"cpuCoreLimit\" is \"0.250\" and meets the threshold criterion \">=0\".;\nThis message is configured in an AOM alarm rule by kaifatest. For more information, go to the AOM console.\",", "smn_subscription_status" : 0, "smn_subscription_type" : "sms" } ], "smn_request_id" : "600bfa7447da48068312bba0fb2b3afa", "smn_response_body" : "{\"message_id\":\"b5db3a3419b84cc29d438a7dba336c20\",\"request_id\":\"600bfa7447da48068312bba0fb2b3afa\"}", "smn_response_code" : "200", "smn_topic" : "lhy_test01" } } ] } ] }
Status code: 401
Unauthorized: The authentication information is incorrect or invalid.
{ "error_code" : "AOM.0403", "error_msg" : "auth failed.", "error_type" : "AUTH_FAILED", "trace_id" : null }
Status code: 403
Forbidden: The request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications.
{ "error_code" : "AOM.0403", "error_msg" : "auth failed.", "error_type" : "AUTH_FAILED", "trace_id" : null }
Status code: 500
Internal Server Error: The server is able to receive the request but unable to understand the request.
{ "error_code" : "APM.00000500", "error_msg" : "Internal Server Error", "trace_id" : "" }
SDK Sample Code
The SDK sample code is as follows.
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.aom.v2.region.AomRegion; import com.huaweicloud.sdk.aom.v2.*; import com.huaweicloud.sdk.aom.v2.model.*; public class ListNotifiedHistoriesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); AomClient client = AomClient.newBuilder() .withCredential(auth) .withRegion(AomRegion.valueOf("<YOUR REGION>")) .build(); ListNotifiedHistoriesRequest request = new ListNotifiedHistoriesRequest(); try { ListNotifiedHistoriesResponse response = client.listNotifiedHistories(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkaom.v2.region.aom_region import AomRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkaom.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = AomClient.new_builder() \ .with_credentials(credentials) \ .with_region(AomRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListNotifiedHistoriesRequest() response = client.list_notified_histories(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" aom "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := aom.NewAomClient( aom.AomClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListNotifiedHistoriesRequest{} response, err := client.ListNotifiedHistories(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
200 |
OK: The request is successful. |
401 |
Unauthorized: The authentication information is incorrect or invalid. |
403 |
Forbidden: The request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications. |
500 |
Internal Server Error: The server is able to receive the request but unable to understand the request. |
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