Reviewed-by: Bobkova, Natalia <natalia.bobkova@t-systems.com> Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: liusiying77 <liusiying@huawei.com> Co-committed-by: liusiying77 <liusiying@huawei.com>
34 KiB
Querying the Active or Historical Alarm List
Function
This API is used to query the alarm list.
URI
POST /v2/{project_id}/{domain_id}/lts/alarms/sql-alarm/query
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
domain_id |
Yes |
String |
Account ID. For details about how to obtain an account ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Minimum: 32 Maximum: 32 |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
type |
Yes |
String |
Whether the alarm is an active alarm or a historical alarm. |
marker |
No |
String |
The value is the ID of the last record on the previous page (value of previous_marker or next_marker returned by the previous page). Minimum: 0 Maximum: 1000 |
limit |
No |
Integer |
Number of records on each page. Minimum: 0 Maximum: 1000 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token. Minimum: 1000 Maximum: 2000 |
Content-Type |
Yes |
String |
Set this parameter to application/json;charset=UTF-8. Minimum: 30 Maximum: 30 |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
whether_custom_field |
Yes |
Boolean |
Whether to customize the query time segment. |
start_time |
No |
Long |
Start time of a customized time segment (timestamp). Minimum: 13 Maximum: 13 |
end_time |
No |
Long |
End time of a customized time segment (timestamp). Minimum: 13 Maximum: 13 |
time_range |
No |
String |
Time range specified to query data of the last N minutes when the client time is inconsistent with the server time. It can also be used to accurately query the data of a specified period. Examples:
Minimum: 1 Maximum: 32 |
search |
No |
String |
Field specified for fuzzy query, which can be left blank. If the value is not empty, fuzzy match will be performed. The metadata field is mandatory. Minimum: 1 Maximum: 1024 |
alarm_level_ids |
No |
Array of strings |
Alarm severity (Critical, Major, Minor, Info). NOTE:
alarmLevelIds is a parameter of an earlier version and is currently compatible with this parameter. You are advised to use this parameter. alarm_level_ids |
sort |
No |
Sort object |
Sorting order, which can be left blank. |
step |
No |
Integer |
Statistical step. Unit: ms. For example, if the duration is 1 minute, set this parameter to 60000. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
|---|---|---|
events |
Array of Events objects |
Alarm information. |
page_info |
PageInfo object |
Pagination details. |
Parameter |
Type |
Description |
|---|---|---|
annotations |
Annotations object |
Alert details. |
metadata |
Metadata object |
Alarm information. |
arrives_at |
Long |
Arrival time (timestamp). |
ends_at |
Long |
Alarm clearance time (timestamp). |
id |
String |
Alarm ID. |
starts_at |
Long |
Alarm generation time (timestamp). |
timeout |
Long |
Time when an alarm is automatically cleared (timestamp). |
type |
String |
Alarm rule type (SQL/keyword). |
Parameter |
Type |
Description |
|---|---|---|
message |
String |
Alarm list details. |
log_info |
String |
Log group/stream ID. |
current_value |
String |
Current value. |
old_annotations |
String |
Original data of (SQL/keyword) alarm details. |
Parameter |
Type |
Description |
|---|---|---|
event_type |
String |
Alarm type. |
event_id |
String |
Alarm ID. |
event_severity |
String |
Alarm severity. |
event_name |
String |
Alarm name. |
resource_type |
String |
Resource type. |
resource_id |
String |
Log group/stream name. |
resource_provider |
String |
Alarm source. |
lts_alarm_type |
String |
Alarm rule type (SQL/keyword). |
Parameter |
Type |
Description |
|---|---|---|
next_marker |
String |
Address of the next page. If this parameter is left empty, no data is displayed on the next page. |
previous_marker |
String |
Address of the previous page. |
current_count |
String |
Number of items returned on this page. |
Status code: 400
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 500
Parameter |
Type |
Description |
|---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Example Requests
Querying the active or historical alarm list
POST https://{endpoint}/v2/{project_id}/{domain_id}/lts/alarms/sql-alarm/query?type=active_alert
{
"whether_custom_field" : false,
"start_time" : 0,
"end_time" : 0,
"time_range" : "30",
"search" : "",
"alarm_level_ids" : [ "Critical", "Major", "Minor", "Info" ],
"sort" : {
"order_by" : [ "starts_at" ],
"order" : "desc"
}
}
Example Responses
Status code: 200
The request is successful.
{
"events" : [ {
"annotations" : {
"current_value" : "{\"pv\":30}",
"log_info" : "[{\"log_group_id\":\"50bcab14-xxxx-xxxx-xxxx-41ae4a6e3401\",\"log_group_name\":\"lts-test-group\",\"log_group_name_alias\":\"lts-test-group\",\"log_stream_id\":\"90727e60-xxxx-xxxx-xxxx-19ba53adcbc5\",\"log_stream_name\":\"lts-test-topic\",\"log_stream_name_alias\":\"lts-test-topic\"}]",
"message" : "{\"alarm_action_rule_name\":\"testlts\",\"alarm_rule_alias\":\"lts001\",\"alarm_rule_id\":\"2ef849e9-afb4-4983-9197-9049c3460b9d\",\"alarm_rule_name\":\"lts001\",\"closed_alarm_time\":0,\"condition_expression\":\"pv > 0\",\"condition_expressions\":[{\"condition_expression\":\"pv > 0\"}],\"create_time\":0,\"domain_id\":\"1d26cc8c86a840e28a4f8dxxxxxxxxxx\",\"frequency\":{\"day_of_week\":1,\"fixed_rate\":1,\"fixed_rate_unit\":\"minute\",\"hour_of_day\":0,\"type\":\"FIXED_RATE\"},\"is_css_sql\":true,\"ltsAlarmInfos\":[{\"conditions\":[],\"is_time_range_relative\":true,\"log_group_id\":\"50bcab14-xxxx-xxxx-xxxx-41ae4a6e3401\",\"log_group_name\":\"lts-test-group\",\"log_group_name_alias\":\"lts-test-group\",\"log_stream_id\":\"90727e60-xxxx-xxxx-xxxx-19ba53adcbc5\",\"log_stream_name\":\"lts-test-topic\",\"log_stream_name_alias\":\"lts-test-topic\",\"search_time_range\":5,\"search_time_range_unit\":\"minute\",\"sql\":\"* | SELECT count(*) as pv\",\"sql_request_title\":\"\"}],\"notification_frequency\":0,\"projectId\":\"\",\"status\":\"RUNNING\",\"topics\":[],\"type\":\"sql\",\"update_time\":0,\"whether_recovery_policy\":false}"
},
"metadata" : {
"event_type" : "alarm",
"event_id" : "2ef849e9-xxxx-xxxx-xxxx-9049c3460b9d",
"lts_alarm_type" : "search_analysis",
"event_severity" : "Critical",
"resource_type" : "Log group/stream.",
"event_name" : "lts001",
"resource_id" : "lts-test-group/lts-test-topic",
"event_subtype" : "sql",
"resource_provider" : "LTS"
},
"type" : "search_analysis"
} ]
}
Status code: 400
Response content.
{
"error_code" : "LTS.2005",
"error_msg" : "Find alarm error start_time or end_tim must not be empty."
}
Status code: 500
Response content.
{
"error_code" : "LTS.0010",
"error_msg" : "Internal Server Error"
}
Status Codes
Status Code |
Description |
|---|---|
200 |
The request is successful. |
400 |
Response content. |
500 |
Response content. |
Error Codes
See Error Codes.