1

我正在 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 |
+----------------+-------+

是否有可能做到这一点?我在寻找什么术语?

4

1 回答 1

3

这是一种方法:

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])
于 2019-10-15T10:50:43.553 回答