本文档介绍告警输出的数据结构。
告警输出至事件库的数据结构
告警输出至事件库(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.aliyun.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.aliyun.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"
}
告警输出到云监控事件中心数据结构
|
字段名称 |
类型 |
说明 |
示例 |
|
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 |