azure - Kustos bag_unpack 没有解压我的 json 字典字符串
问题描述
我有以下数据,我想在 Kusto 中将其拆分为几列,以访问字典条目的值:
这是我用来从图片中获取表格的代码:
let latestVersionAndroid = toscalar(customEvents
| where client_OS contains "Android"
| summarize max(application_Version));
let releaseDateLatestAndroid = toscalar(customEvents
| where client_OS contains "Android" and application_Version contains latestVersionAndroid
| summarize min(timestamp));
customEvents
| where timestamp > releaseDateLatestAndroid
and name == 'Login'
and client_OS contains 'Android'
and application_Version == latestVersionAndroid
| project properties = customDimensions.Properties, application_Version
| evaluate bag_unpack(properties)
我认为最后一行将展开属性的内容并从中创建一个新表。但正如您在图像中看到的那样,它只是显示与没有评估线相同的结果。是因为键中有空格可用作列名吗?但是,如果 kusto 因此无法完成操作,我会抛出异常吗?是否有另一种方法可以在 Kusto 中提取数据以访问键的值?
非常感谢,特立独行
解决方案
这可能是因为看起来像 json 的“属性”实际上是一个字符串。如果是这种情况,您应该尝试将 json 解析为字符串,然后执行 bag_unpack。例如更改此行:
| project properties = customDimensions.Properties, application_Version
对此:
| project properties = parse_json(tostring(customDimensions.Properties)), application_Version
为了使用空格访问列,您需要将它们放入方括号中,如下所示
| summarize count()
by application_Version, ["DW version"]
推荐阅读
- mongoose - 如何在 Prisma 中添加前/后保存中间件?
- python - CNN ERROR 参数无效:所有标签必须是非负整数,批次:10 个标签:-1、-1、-1、-1、-1、-1
- flutter - 一个使用 TabBarView 的选项卡包含多个方法 [Flutter]
- amazon-web-services - 如何将日志从 VPC A 中的 EC2 推送到 VPC B 中的弹性搜索
- django - 如何使 django 关联引用自身
- c# - 我无法通过 Postman “Autofac.Core.DependencyResolutionException”将图像添加到我的 WebAPI 和 SQL 数据
- mysql - MySQL选择具有一个重复值和一个不同值的记录
- visual-studio - 如何一次通过 Visual Studio Live Share 共享多个 .cpp 和 .h 文件?
- orbeon - orbeon 客户端 ajax 调用者发送 /xforms-server POST 时缺少 JSESSIONID
- python - 使用 Python 抓取 Web 的问题