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

KQL查询协助:提取customDimensions中Filter类字段标识

KQL查询实现过滤器使用频次统计
// 替换成你的App Insights日志表名(通常是requests或traces)
requests
// 展开customDimensions的键值对,每个键值对单独成一行
| mv-expand customDimensions = bag_pack(customDimensions)
// 提取键和值字段
| extend Key = tostring(bag_keys(customDimensions)[0]), Value = tostring(customDimensions[Key])
// 只保留Filter_开头的键
| where startswith(Key, "Filter_")
// 从键中提取冒号后的过滤器类型,比如Filter_0:School → School
| extend FilterType = split(Key, ":")[1]
// 按过滤器类型分组统计使用频次
| summarize UsageCount = count() by FilterType
// 按使用次数倒序排列,优先展示高频过滤器
| sort by UsageCount desc

步骤拆解:

  • mv-expand + bag_pack:把customDimensions这个JSON对象拆成一行行的键值对,让每个Filter_开头的字段能单独处理。
  • extend Key/Value:从展开的对象里提取出具体的键和值,方便后续筛选和提取。
  • where startswith:过滤掉所有非Filter_开头的键,只保留我们关心的过滤器字段。
  • extend FilterType:用split函数把键按冒号:分割,取分割后的第二个元素(KQL数组索引从0开始),得到过滤器的类型(比如School、Level)。
  • summarize:按过滤器类型分组,统计每个类型的总使用次数。
  • sort:按使用次数倒序排列,直观展示高频过滤器。

异常处理补充:

如果遇到少数键格式不符合Filter_*:*的情况(比如没有冒号),可以在提取FilterType前加判断过滤异常数据:

| where array_length(split(Key, ":")) >= 2

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 20:02:42