KQL-建立多個table

KQL 是一種查詢語言,用於對資料進行分析,以建立分析、workbooks,並在 Microsoft Sentinel 中執行搜尋。了解如何將不同表中的資料與 KQL 語句關聯起來,為在 Microsoft Sentinel 中建立檢測奠定了基礎。

union operator

union operator採用兩個或多個table並傳回所有table的rows。了解結果如何傳遞以及如何影響pipe character至關重要。

基於Query window中設定的時間視窗:

  • Query 1 傳回 SecurityEvent 和 SigninLogs 的所有rows
  • Query 2傳回one row and column,即SecurityEvent和SigninLogs所有rows的計數
  • Query 3 傳回 SecurityEvent 的所有rows和 SigninLogs 的一個row。

單獨執行每個查詢以查看結果。

// Query 1

SecurityEvent
| union SigninLogs

// Query 2

SecurityEvent
| union SigninLogs
| summarize count()
| project count_

// Query 3

SecurityEvent
| union (SigninLogs | summarize count()| project count_)

union 支援wildcards來合併多個tables。以下 KQL 為名稱以 Security 開頭的所有tables中的rows建立計數。

union Security* 
| summarize count() by Type

join operator

join operator透過匹配每個tables中指定column的值來合併兩個table的column以形成一個new table。

Syntax:
LeftTable | join [JoinParameters] ( RightTable ) on Attributes

SecurityEvent 
| where EventID == "4624"
| summarize LogOnCount=count() by EventID, Account
| project LogOnCount, Account
| join kind = inner (
SecurityEvent
| where EventID == "4634"
| summarize LogOffCount=count() by EventID, Account
| project LogOffCount, Account
) on Account

Join中指定的第一個table被視為Left table。 join keywords後面的table是right table。Table中的欄位被指定為 $left.Column 和 $right.Column,以區分引用的tables columns。

Join table時,可以使用Join flavors來確定join行為。根據Join flavors了解左側和右側記錄的影響至關重要。下圖顯示如果其他資料集中存在或不存在匹配記錄,則將保留哪些記錄。如果右側有符合的記錄,則內部聯結將僅顯示左側的記錄。右側還需要左側記錄。

--

--

運用"雲端服務"加速企業的數位轉型願景
運用"雲端服務"加速企業的數位轉型願景

Written by 運用"雲端服務"加速企業的數位轉型願景

我們協助您駕馭名為"雲端運算"的怪獸,馴服它為您所用。諮詢請來信jason.kao@suros.com.tw. https://facebook.com/jason.kao.for.cloud

No responses yet