You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在KQL中利用含双字段的Watchlist创建白名单查询?

多字段Watchlist排除的KQL实现方法

要筛选出用户邮箱+国家代码组合不在目标Watchlist里的事件,核心是验证两个字段的组合匹配关系,而非单字段独立匹配。以下是两种可行的KQL写法:

方法1:用leftouter join筛选不匹配记录

假设你的事件表是SecurityEvent,事件内邮箱字段为UserEmail、国家代码字段为CountryCode;Watchlist名称为AllowedUserCountryPairs,内部对应字段同样是UserEmail和CountryCode。

SecurityEvent
| leftouter join kind=leftouter (
    _GetWatchlist('AllowedUserCountryPairs')
) on UserEmail, CountryCode
// 只保留未匹配到Watchlist的事件
| where isempty(UserEmail1)  // UserEmail1是join后Watchlist字段的自动重命名,可根据实际调整

方法2:用where not exists子查询(性能更优)

这种写法直接在主查询中排除存在匹配组合的事件,执行效率通常更高:

SecurityEvent
| where not exists (
    _GetWatchlist('AllowedUserCountryPairs')
    | where UserEmail == SecurityEvent.UserEmail and CountryCode == SecurityEvent.CountryCode
)

注意事项

  • 确保事件表与Watchlist的字段名称完全一致,若不一致可先用rename统一,比如事件里邮箱字段是user_principal_name,Watchlist里是Email,就先执行rename user_principal_name to UserEmail。
  • 若Watchlist是自定义上传的,可直接用Watchlist的表名(如AllowedUserCountryPairs)替代_GetWatchlist()调用。

内容的提问来源于stack exchange,提问作者JohnnyMnemonic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 18:32:01