我正在使用victoriametrics从物联网数据中记录设备。每次设备向服务器发送心跳时,我都会推送到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"
]第二个给出值,但它给出了24小时内的所有值。结果导致更多的带宽,更低的效率,因为我想为许多设备运行脚本。
"values": [
... All day values
[
1620822770.508,
"20848"
],
[
1620823070.518,
"21148"
],
[1620823370.528,
"21448"
]
]有没有一种正确的方法来获取设备最后一次出现的时间?
发布于 2021-05-13 14:22:20
第一个给出值,但时间戳不是事件的实际时间。
这是/query端点的特性-它在当前时间戳执行即时查询并返回最接近的结果。
您是否尝试过"tlast_over_time(md) -return timestamp for the last sample for the last sample for m over d time range“以获取时间戳?请参阅更多详细信息here。
https://stackoverflow.com/questions/67504056
复制相似问题