将列表中的部分字符串与字段匹配

Chr*_*erL 0 azure-log-analytics kql azure-sentinel

我正在尝试使用 Azure 中的日志分析/Sentinel 中的 Kusto 检查字段是否包含列表中的值。

该列表包含顶级域,但我只想匹配这些顶级域的子域。列表值 example.com 应与 forum.example.com 或 api.example.com 等值匹配。

我得到了以下代码,但它仅精确匹配。

let domains = dynamic(["example.com", "amazon.com", "microsoft.com", "google.com"]);
DeviceNetworkEvents
| where RemoteUrl in~ (domains)
| project TimeGenerated, DeviceName, InitiatingProcessAccountUpn, RemoteUrl
Run Code Online (Sandbox Code Playgroud)

我尝试使用endswith,但无法使其与列表一起使用。

Avn*_*era 5

看来has_any()适合你:

let domains = dynamic(["example.com", "amazon.com", "microsoft.com", "google.com"]);
DeviceNetworkEvents
| where RemoteUrl has_any(domains)
| project TimeGenerated, DeviceName, InitiatingProcessAccountUpn, RemoteUrl
Run Code Online (Sandbox Code Playgroud)

请注意,您还可以使用has_any_index()来获取数组中的哪一项被匹配