首页 > 解决方案 > Kusto 查询语言:通过评估表达式设置汇总的列名

问题描述

我再次问了另一个与 Kusto 相关的问题(我真的希望在某个地方有一个完整的视频教程)。

我有一个summarize语句,它为 y 轴生成两列,为 x 轴生成一列。现在我想重新标记 x 轴的列以显示一个字符串,该字符串也是我从数据库中获取的,并且已经放入一个带有let.

这基本上看起来像这样:

let android_col = strcat("Android: ", toscalar(customEvents
| where application_Version contains secondLatestVersionAndroid));
let iOS_col = strcat("iOS: ", toscalar(customEvents
| where application_Version contains secondLatestVersionIOS));

... some Kusto magic ...

| summarize
    Android = 100 - (round((countif(hasUnhandledErrorAndroid == 1 ) * 100.0 ) / countif(isAndroid == 1), 2)),
    iOS = 100 - (round((countif(hasUnhandledErroriOS == 1) * 100.0 ) / countif(isIOS == 1), 2))
    by Time
|render timechart with (ytitle="crashfree users in %", xtitle="date", legend=visible )

现在我想要汇总显示的不是 Android 和 iOS,而是 android_col 和 iOS_col 的值。

那可能吗?

最好的问候特立独行

标签: azureazure-log-analyticsazure-data-explorerkql

解决方案


一般来说,建议使用预定义的列名,否则各种功能都不起作用。例如,IntelliSense 不知道列的名称,因为它们仅在运行时确定。此外,如果您创建一个返回动态模式的函数,您将无法从其他集群运行此函数。

但是,如果您确实想更改列名,您肯定有办法通过使用各种插件来做到这一点。例如bag_unpackpivot等。

至于 Kusto 上的课程,其实 Pluralsight 上有几门优秀的课程(都是免费的):


推荐阅读