ADX Kusto找到了多个ID元组的最新行
鉴于我有具有ID的设备,并且每个设备都有不同的遥测方面,这些方面存储在ADX表中。这些方面中的每一个都通过telemetryid
识别。 DeviceID
是唯一的,但是telemetryid
不是。该设备 - 元件元组作为ADX中的单个行存储。因此表看起来像:
|DeviceId|TelemetryId|Value|TimeStamp|
|--------|-----------|-----|----------------------------|
|1 | 1 | 10 | 2022-06-15 08:50:42.016496 |
|1 | 2 | 20 | 2022-06-15 08:50:41.072425 |
|1 | 3 | 30 | 2022-06-15 08:50:40.199198 |
|2 | 1 | 11 | 2022-06-15 08:50:39.366868 |
|2 | 2 | 22 | 2022-06-15 08:50:38.536320 |
|2 | 3 | 33 | 2022-06-15 08:50:37.602781 |
|2 | 4 | 44 | 2022-06-15 08:50:36.702367 |
|2 | 5 | 55 | 2022-06-15 08:50:35.677494 |
|1 | 1 | 12 | 2022-06-15 08:50:34.750020 |
|1 | 2 | 22 | 2022-06-15 08:50:33.752211 |
现在我需要有关最新数据的信息,其中包含特定deviceID
的所有远程数据数据。从查询消费者的角度来看,我知道系统中存在哪个deviceId
,哪个telemetryid
分配给每个device> deviced
。因此,我可以使用此信息来构建查询。
因此,例如,如果我要查询deviceID == 1
我会期望这个结果:
|DeviceId|TelemetryId|Value|TimeStamp|
|--------|-----------|-----|----------------------------|
|1 | 1 | 10 | 2022-06-15 08:50:42.016496 |
|1 | 2 | 20 | 2022-06-15 08:50:41.072425 |
|1 | 3 | 30 | 2022-06-15 08:50:40.199198 |
但是我不确定是否可以使用单个kusto查询来实现这一点? (我知道如何使用多个ADX查询(对于每个设备 - 特里元组的一个查询),但我想知道是否可以使用一个查询来完成它)。
Given I have Devices with an ID and each Device has different telemetry aspects which are stored to an ADX table. Each of these aspects is identified by a TelemetryId
. The DeviceId
is unique, but the TelemetryId
is not. This Device-Telemery tuples are stored as individual rows in ADX. So the table looks like:
|DeviceId|TelemetryId|Value|TimeStamp|
|--------|-----------|-----|----------------------------|
|1 | 1 | 10 | 2022-06-15 08:50:42.016496 |
|1 | 2 | 20 | 2022-06-15 08:50:41.072425 |
|1 | 3 | 30 | 2022-06-15 08:50:40.199198 |
|2 | 1 | 11 | 2022-06-15 08:50:39.366868 |
|2 | 2 | 22 | 2022-06-15 08:50:38.536320 |
|2 | 3 | 33 | 2022-06-15 08:50:37.602781 |
|2 | 4 | 44 | 2022-06-15 08:50:36.702367 |
|2 | 5 | 55 | 2022-06-15 08:50:35.677494 |
|1 | 1 | 12 | 2022-06-15 08:50:34.750020 |
|1 | 2 | 22 | 2022-06-15 08:50:33.752211 |
Now I need the information about the most recent data containing all Telementry data for a specific DeviceId
. From the query consumer perspective, I know which DeviceId
exist in the system and which TelemetryId
are assigned to each DeviceId
. So I can use this information to build the query.
So for example, if I would query for DeviceId == 1
I would expect this result:
|DeviceId|TelemetryId|Value|TimeStamp|
|--------|-----------|-----|----------------------------|
|1 | 1 | 10 | 2022-06-15 08:50:42.016496 |
|1 | 2 | 20 | 2022-06-15 08:50:41.072425 |
|1 | 3 | 30 | 2022-06-15 08:50:40.199198 |
But I’m not sure if this can be achieved with a single Kusto Query? (I know how to do it with multiple ADX queries (one query for each Device-Telemetry tuple) but I am wondering if it is possible to get it done with one Query).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
arg_max(
)绩效原因,您应该考虑在应用聚合之前通过时间戳缩小数据集,例如仅查询最后一周/天/小时,取决于您的数据摄入行为。
arg_max()
For performance reasons, you should consider narrowing the dataset by TimeStamp before applying the aggregation, E.g. querying only the last week/day/hour, depends on your data ingestion behaviour.
Fiddle