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

KQL中从ReconDarknetDetectionAlerts_CL表提取Email与Breach Date字段求助

解决KQL中从JSON格式字段提取Email和Breach Date的问题

你的ReconDarknetDetectionAlerts_CL表中tables_s是未解析的JSON字符串,直接用正则提取容易出错且不可靠,应该用KQL的JSON解析函数来处理,以下是正确的实现方式:

方法一:按固定索引提取(适合字段顺序固定的场景)

ReconDarknetDetectionAlerts_CL
| extend tables_dynamic = parse_json(tables_s)  // 将字符串转成动态JSON对象
| mv-expand tables_dynamic  // 展开外层数组
| mv-expand value = tables_dynamic.values  // 展开values里的每一行数据
| extend Email = value[0], BreachDate = value[4]  // 根据headers顺序取对应位置的值
| project-away tables_s, tables_dynamic, value  // 移除不需要的中间字段(可选)

方法二:按headers映射提取(更健壮,字段顺序变化也不影响)

这种方法会先根据headers的名称找到对应值的索引,再提取数据,适合字段顺序可能变动的场景:

ReconDarknetDetectionAlerts_CL
| extend tables_dynamic = parse_json(tables_s)
| mv-expand tables_dynamic
| extend headers = tables_dynamic.headers, values = tables_dynamic.values
| mv-expand value = values
| extend email_index = indexof(headers, "Email"), breach_date_index = indexof(headers, "Breach Date")
| extend Email = value[email_index], BreachDate = value[breach_date_index]
| project-away tables_s, tables_dynamic, headers, values, value, email_index, breach_date_index

原语句报错原因

原语句用extract_all正则匹配邮箱,一方面JSON字符串里的引号、转义字符会干扰正则匹配,导致提取失败;另一方面无法关联对应的Breach Date,只能单独提取邮箱,不符合需求。用JSON解析的方式能完整保留字段间的对应关系,更准确可靠。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 04:43:17