事件(Event)是指值得關注的、有價值的數據。例如監控告警數據、定期巡檢作業的結果等。
格式
日志服務的事件數據遵循CloudEvents協議規范,具體說明如下表所示。
字段類型 | 字段名 | 是否必選 | 數據格式 | 說明 |
協議字段 |
| 是 | String | 根據CloudEvents協議規范,默認使用 |
| 是 | String | 事件ID,您可以根據 | |
| 是 | String | 通常用來標識事件發生的上下文信息,例如事件來源、發布事件的實例等。 | |
| 是 | String | 事件類型,例如 | |
| 否 | String | 事件主題,是對 | |
| 否 | String | 事件類型,默認取值為 | |
| 否 | URI |
| |
| 否 | JSON | 具體的事件內容。不同來源和類型的事件格式會有差異。 | |
| 是 | Timestamp | 事件時間,具體格式,請參見RFC 3339。例如 | |
擴展字段 |
| 是 | String | 事件標題。 |
| 是 | String | 事件描述。 | |
| 是 | String | 事件狀態。取值:
|
示例
例如一個告警事件,示例數據如下:
{
"specversion": "1.0",
"id": "af****6c",
"source": "acs:sls",
"type": "sls.alert",
"subject": "https://sls.console.aliyun.com/lognext/project/demo-alert-chengdu/logsearch/nginx-access-log?encode=base64&endTime=1684312259&queryString=c3RhdHVzID49IDQwMCB8IHNlbGVjdCByZXF1ZXN0X21ldGhvZCwgY291bnQoKikgYXMgY250IGdyb3VwIGJ5IHJlcXVlc3RfbWV0aG9kIA%3D%3D&queryTimeType=99&startTime=1684311959",
"datacontenttype": "application/cloudevents+json",
"data": {
"aliuid": "16****50",
"region": "cn-chengdu",
"project": "demo-alert-chengdu",
"alert_id": "alert-16****96-247190",
"alert_name": "Nginx訪問錯誤",
"alert_instance_id": "77****e4-1aad9f7",
"alert_type": "sls_alert",
"next_eval_interval": 300,
"fire_time": 1684299959,
"alert_time": 1684312259,
"resolve_time": 0,
"status": "firing",
"severity": 10,
"labels": {
"request_method": "GET"
},
"annotations": {
"__count__": "1",
"cnt": "49",
"desc": "Nginx最近五分鐘內GET請求錯誤49次",
"title": "Nginx訪問錯誤告警觸發"
},
"results": [
{
"region": "cn-chengdu",
"project": "demo-alert-chengdu",
"store": "nginx-access-log",
"store_type": "log",
"role_arn": "",
"query": "status >= 400 | select request_method, count(*) as cnt group by request_method ",
"start_time": 1684311959,
"end_time": 1684312259,
"fire_result": {
"cnt": "49",
"request_method": "GET"
},
"raw_results": [
{
"cnt": "49",
"request_method": "GET"
},
{
"cnt": "3",
"request_method": "DELETE"
},
{
"cnt": "7",
"request_method": "POST"
},
{
"cnt": "6",
"request_method": "PUT"
}
],
"raw_result_count": 4,
"truncated": false,
"dashboard_id": "",
"chart_title": "",
"is_complete": true,
"power_sql_mode": "auto"
}
],
"fire_results": [
{
"cnt": "49",
"request_method": "GET"
}
],
"fire_results_count": 1,
"condition": "Count:[1] > 0; Condition:[49] > 20",
"raw_condition": "Count:__count__ > 0; Condition:cnt > 20"
},
"time": "2023-05-17T08:30:59Z",
"title": "Nginx訪問錯誤告警觸發",
"message": "Nginx最近五分鐘內GET請求錯誤49次",
"status": "error"
}
文檔內容是否對您有幫助?