本文檔介紹警示輸出的資料結構。
警示輸出至事件庫的資料結構
警示輸出至事件庫(EventStore)的資料格式請參見事件數目據(Event),具體欄位說明及樣本如下。
|
欄位名稱 |
類型 |
說明 |
樣本 |
|
specversion |
string |
固定為1.0。 |
1.0 |
|
id |
string |
事件ID。 |
568f2****2757 |
|
source |
string |
事件來源。固定為 |
acs:sls |
|
type |
string |
事件類型。固定為 |
sls.alert |
|
subject |
string |
警示的查詢快照。 |
https://sls.console.alibabacloud.com/lognext/project/test-xxx/logsearch/test-alert-access?encode=base64&endTime=1617175989&queryString=KiB8IHNlKiB8IHNlbGVjdCBjb3VudCgxKSBhcyBjbn****meType=99&startTime=1617175089 |
|
datacontenttype |
string |
資料格式。固定為 |
application/cloudevents+json |
|
data |
json |
事件數目據。資料格式請參見警示資料結構。 |
/ |
|
time |
string |
警示時間。 |
2023-05-31T01:49:18Z |
|
title |
string |
警示資訊標題。 |
Nginx 400錯誤。 |
|
message |
string |
警示資訊描述。 |
Nginx 過去5分鐘內,400錯誤發生156次。 |
|
status |
string |
警示事件狀態。
|
error |
樣本資料如下:
{
"specversion": "1.0",
"id": "568f****2757",
"source": "acs:sls",
"type": "sls.alert",
"subject": "https://sls.console.alibabacloud.com/lognext/project/test-xxx/logsearch/test-alert-access?encode=base64&endTime=1617175989&queryString=KiB8IHNlbGVjdCBjb3VudCgxKSBhcyBjbnQ%3D&queryTimeType=99&startTime=1617175089",
"datacontenttype": "application/cloudevents+json",
"data": {
// ...
},
"time": "2023-05-31T01:49:18Z",
"title": "Nginx 400錯誤",
"message": "Nginx 過去5分鐘內,400錯誤發生156次。",
"status": "warning"
}
警示輸出到CloudMonitor事件中心資料結構
|
欄位名稱 |
類型 |
說明 |
樣本 |
|
Product |
string |
產品名稱。固定為 |
SLS |
|
Name |
string |
事件名稱。
|
AlertEvent:WARN |
|
Time |
int |
毫秒級時間戳記。 |
1685499264000 |
|
Level |
string |
事件等級。
|
WARN |
|
RegionId |
string |
地區。 |
cn-hangzhou |
|
Status |
string |
事件狀態,可能的取值為:
|
firing |
|
InstanceName |
string |
警示規則名稱。 |
測試警示規則 |
|
ResourceId |
string |
資源ID。格式為 |
acs:log:cn-hangzhou:117918634953****:project/my-project/job/alert-12345 |
|
Content |
json |
事件內容。資料格式請參見警示資料結構。 |
樣本資料如下:
{
"Product": "SLS",
"Name": "AlertEvent:WARN",
"Time": 1685499264000,
"Level": "WARN",
"RegionId": "cn-hangzhou",
"Status": "firing",
"InstanceName": "測試警示規則",
"ResourceId": "acs:log:cn-hangzhou:117918634953****:project/my-project/job/alert-1683858496-247190",
"Content": {
// ...
}
}
警示資料結構
|
欄位名稱 |
類型 |
說明 |
樣本 |
|
aliuid |
string |
Project所屬的阿里雲帳號ID。 |
117918634953**** |
|
region |
string |
地區。 |
cn-hangzhou |
|
project |
string |
警示規則所屬Project。 |
my-project |
|
alert_id |
string |
警示規則ID,Project內唯一。 |
alert-12345 |
|
alert_name |
string |
警示規則名稱。 |
測試警示規則 |
|
alert_instance_id |
string |
警示觸發的執行個體的ID。 |
ee16a8f435485f3f-5be6b81edc520-3d6**** |
|
alert_type |
string |
警示類型。預設為 |
sls_alert |
|
next_eval_interval |
int |
下一次評估間隔,單位為秒。 |
300 |
|
fire_time |
int |
首次觸發時間,秒級時間戳記。 |
1616059834 |
|
alert_time |
int |
本次評估時間,秒級時間戳記。 |
1616744734 |
|
resolve_time |
int |
警示恢復,秒級時間戳記。
|
0 |
|
status |
string |
警示狀態。可能的取值為:
|
firing |
|
severity |
int |
警示嚴重度。可能的取值為:
|
6 |
|
labels |
map |
警示標籤。 |
|
|
annotations |
map |
警示標註。 |
|
|
results |
array |
查詢參數和中間結果,數群組類型。資料格式請參見警示查詢結果資料結構。 |
/ |
|
fire_results |
array |
觸發警示的資料,最多取100條。 fire_results的值超過2 KB時,超出部分會被截斷。 |
|
|
fire_results_count |
int |
觸發警示的資料的總條數. |
3 |
|
condition |
string |
觸發警示的評估運算式。其中,以觸發警示的值替換您所配置的變數,並使用中括弧([ ])包裹。格式為 |
Count:[4] > 0; Condition:[400] >= 400 |
|
raw_condition |
string |
原始的評估運算式,即變數未被替換為真實值的原始運算式。格式為 |
Count:__count__ > 0; Condition:status >= 400 |
樣本資料如下:
{
"aliuid": "117918634953****",
"region": "cn-hangzhou",
"project": "my-project",
"alert_id": "alert-****-247190",
"alert_name": "Nginx訪問錯誤",
"alert_instance_id": "77df****5a2a",
"alert_type": "sls_alert",
"next_eval_interval": 300,
"fire_time": 1686719199,
"alert_time": 1686722799,
"resolve_time": 0,
"status": "firing",
"severity": 4,
"labels": {
"request_method": "POST"
},
"annotations": {
"__count__": "1",
"cnt": "5",
"desc": "Nginx最近五分鐘內POST請求錯誤5次",
"title": "Nginx訪問錯誤警示觸發"
},
"results": [
{
"region": "cn-hangzhou",
"project": "my-project",
"store": "nginx-access-log",
"store_type": "log",
"role_arn": "",
"query": "status >= 400 | select request_method, count(*) as cnt group by request_method ",
"start_time": 1686722499,
"end_time": 1686722799,
"fire_result": {
"cnt": "5",
"request_method": "POST"
},
"raw_results": [
{
"cnt": "25",
"request_method": "GET"
},
{
"cnt": "2",
"request_method": "DELETE"
},
{
"cnt": "5",
"request_method": "PUT"
},
{
"cnt": "5",
"request_method": "POST"
}
],
"raw_result_count": 4,
"truncated": false,
"dashboard_id": "",
"chart_title": "",
"is_complete": true,
"power_sql_mode": "auto"
}
],
"fire_results": [
{
"cnt": "5",
"request_method": "POST"
}
],
"fire_results_count": 1,
"condition": "Count:[1] > 0; Condition:[5] > 0",
"raw_condition": "Count:__count__ > 0; Condition:cnt > 0"
}
警示查詢結果資料結構
|
欄位名稱 |
類型 |
說明 |
樣本 |
|
region |
string |
查詢統計目標庫所在地區。store_type為資源資料時,該變數值為空白。 |
cn-hangzhou |
|
project |
string |
查詢統計目標庫所在Project。store_type為資源資料時,該變數值為空白。 |
my-project |
|
store_type |
string |
查詢統計目標庫儲存類型。
|
log |
|
store |
string |
查詢統計中的目標庫名稱。 |
test-LogStore |
|
query |
string |
查詢分析語句。 |
status >= 400 | select status, count(*) as cnt group by status |
|
start_time |
int |
查詢開始時間,秒級時間戳記。store_type為資源資料時,該變數值為空白。 |
1616741485 |
|
end_time |
int |
查詢結束時間,秒級時間戳記。store_type為資源資料時,該變數值為空白。 |
1616745085 |
|
fire_result |
map |
觸發警示的查詢分析結果資料。如果有多條資料,這裡只隨機取一條。 |
|
|
raw_results |
array |
實際查詢內容,數組格式,最多100行。 raw_results的值超過2 KB時,超出部分會被截斷。 |
|
|
raw_result_count |
int |
實際查詢資料的總條數,可能多於100。 |
2 |
|
truncated |
boolean |
raw_results是否被截斷。 |
false |
|
dashboard_id |
string |
關聯的儀錶盤ID。如果未關聯則為空白字串。 |
nginx-access-log_nginx_dashboard_cn |
|
chart_title |
string |
關聯的圖表ID。如果未關聯則為空白字串。 |
dashboard-access-log1556888331551 |
|
role_arn |
string |
授權角色ARN。如果不涉及則為空白字串。具體操作,請參見配置存取控制。 |
acs:ram::117918634953****:role/aliyunslsalertmonitorrole |
|
is_complete |
boolean |
查詢是否精確。 |
true |
|
power_sql_mode |
string |
是否開啟SQL獨享版,取值如下:
|
auto |