如何在不显式指定名称的情况下将 json 键值对投影到列

How to project json key value pair to columns without explicitly specifying name

customDimensions中我有x个key-value对数据(目前只有两个NameChannel作为示例在下面的截图中)

并且我想将它们投影到列 而无需显式指定键的名称 ,以便将来,如果将新的 key-value 对添加到日志,我不必返回并修改查询即可将其显示为新列。

谢谢!

Kusto 查询语言包括 bag_unpack() 插件:https://docs.microsoft.com/en-us/azure/kusto/query/bag-unpackplugin

这是一个例子:

datatable(anotherColumn:int, customDimensions:dynamic)
[
    1, dynamic({"Name":"mfdg",  "Channel":"wer"}),
    2, dynamic({"Name":"mfdg2", "Channel":"wer2"}),
    3, dynamic({"NotAName":2.22, "NotAChannel":7}),
]
| evaluate bag_unpack(customDimensions)

产生:

| anotherColumn | Name  | Channel | NotAName | NotAChannel |
|---------------|-------|---------|----------|-------------|
| 1             | mfdg  | wer     |          |             |
| 2             | mfdg2 | wer2    |          |             |
| 3             |       |         | 2.22     | 7           |