我正在使用 victoriametrics 从 IOT Data 记录设备。每次设备向服务器发送心跳时,我都会推送到 VM。有时设备会离线。在我的应用程序中,我想查询一天中设备的最后一次看到时间。我尝试了几个选项,例如
/query?
last_over_time(devicerecord_uptime{kd_id="807d3a73e0fd"}[24h])
和
/query?
devicerecord_uptime{kd_id="807d3a73e0fd"}[24h]
第一个给出值,但时间戳不是事件的实际时间。
"value": [
1620822177, // This timestamp is time now, not the time of report
"19948"
]
第二个给出了值,但它给出了 24H 期间的所有值。导致带宽增加,效率降低,因为我想为很多设备运行脚本。
"values": [
... All day values
[
1620822770.508,
"20848"
],
[
1620823070.518,
"21148"
],
[1620823370.528,
"21448"
]
]
是否有正确的方法来获取设备的最后一次看到时间?