使用選取和取消選取關鍵字控制資料欄
在「搜尋」和「資訊主頁」中,您可以使用 select 和 unselect 關鍵字,自訂「搜尋」頁面「結果」分頁中「事件」表格,以及資訊主頁小工具中表格顯示的資料欄。
雖然系統預設會顯示「Timestamp」和「Event」欄,但您可以使用 select 和 unselect 關鍵字新增或移除特定 Unified Data Model (UDM) 欄位、outcome 變數或 match 變數,進一步調整檢視畫面。
select 和 unselect 關鍵字為選用,不適用於規則。
select:指定要納入查詢結果的 UDM 欄位、outcome變數或match變數清單。unselect:指定要從查詢結果中排除的 UDM 欄位或變數清單。
使用範例
本節範例說明在搜尋查詢中使用 select 和 unselect 關鍵字的常見語法。
範例:單一事件搜尋
下列查詢會搜尋與 alex-laptop 相關的事件,並將 security_result.about.email 新增為「事件」資料表中的資料欄:
principal.hostname = "alex-laptop"
limit: 10
select: security_result.about.email
範例:多個資料欄
您可以新增多個資料欄,並以半形逗號分隔。資料欄會按照您列出的順序顯示。
principal.hostname = "alex-laptop"
limit: 10
select: network.sent_bytes, security_result.about.email
範例:資料表定義
在資訊主頁中,table 關鍵字會定義資料欄輸出內容,select 或 unselect 則會管理顯示的特定欄位。
metadata.event_type = "USER_LOGIN"
select:
principal.hostname
匯總和統計查詢
在 YARA-L 中,匯總和統計函式通常位於 outcome 區段,而 match 區段則定義匯總基準。
select 和 unselect 區段互斥,可讓使用者納入或排除結果變數、比對變數、事件欄位或實體欄位。
所有 UDM 搜尋都是單一事件搜尋或匯總搜尋 (也稱為「事件統計資料」)。匯總搜尋會指定 match 關鍵字,或在輸出內容中使用匯總函式 (例如 sum 或 count)。
匯總搜尋
stats 指令是匯總資料的主要工具。這項功能會將原始事件資料轉換為匯總安全性指標,eval 指令會逐列轉換欄位層級資料,而 stats 則會執行集合層級匯總 (類似 SQL 中的 GROUP BY)。
範例:匯總搜尋
下列查詢會從最終顯示結果中排除 $count_hostname 變數,以便聚焦於 $count_id metric。
events:
$e.metadata.event_type != "RESOURCE_CREATION"
$e.principal.hostname = $hostname
$id = $e.network.session_id
match:
$hostname over 1h
outcome:
$count_hostname = count($hostname)
$count_id = count($id)
unselect:
$count_hostname
範例:搜尋中的結果變數
您也可以使用含有 select 關鍵字的變數,顯示特定計算結果。以下範例將 $seconds 宣告為結果變數。Events 資料表會將 $seconds 值顯示為資料欄。
principal.hostname = "alex-laptop"
outcome:
$seconds = metadata.event_timestamp.seconds
limit: 10
select: $seconds, security_result.about.email
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求解答。