在其自己的列中获取列名称以呈现饼图

时间:2019-10-15 09:11:23

标签: kusto kusto-query-language

我正在Kusto中​​编写查询以解析来自传感器的心跳数据。这是我写的:

datatable(timestamp:datetime, healthycount:int, unhealthycount:int, origin:string)
[
    datetime(1910-06-11), 10, 1, 'origin',
    datetime(1910-05-11), 9, 2, 'origin'
]
| summarize latest = arg_max(timestamp, *) by origin
| project healthy = healthycount,
    unhealthy = unhealthycount

这将输出如下数据:

+--------------+----------------+
|   healthy    |   unhealthy    |
+--------------+----------------+
|           10 |              1 |
+--------------+----------------+

但是,我想将此数据表示为饼图,但为此,我需要以下格式的数据:

+----------------+-------+
|      key       | value |
+----------------+-------+
| healthy        |    10 |
| unhealthy      |     1 |
+----------------+-------+

是否可以这样做?我要寻找什么术语?

1 个答案:

答案 0 :(得分:2)

这是一种方法:

datatable(timestamp:datetime, healthycount:int, unhealthycount:int, origin:string)
[
    datetime(1910-06-11), 10, 1, 'origin',
    datetime(1910-05-11), 9, 2, 'origin'
]
| summarize arg_max(timestamp, *) by origin
| extend Pack = pack("healthycount", healthycount, "unhealthycount", unhealthycount)
| mv-expand kind=array Pack 
| project key = tostring(Pack[0]), value = toint(Pack[1])