選取和取消選取關鍵字,即可控制資料欄
在「搜尋」和「資訊主頁」中,您可以使用 select 和 unselect 關鍵字,自訂「搜尋」的「結果」分頁中「事件」表格顯示的資料欄,以及資訊主頁小工具中的表格。
「時間戳記」和「事件」資料欄預設會顯示,但您可以透過 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 專業人員尋求答案。