Google IOT 后端多久更新一次设备状态?
How often does the Google IOT backend update Device State?
我每分钟在下面执行一次 GET URL 以获取我的 IOT 注册表中所有设备的设备状态
GET https://cloudiot.googleapis.com/v1/{name=projects/*/locations/*/registries/*/devices/*}
获得 Device 后,我有兴趣确定以下字段是否在当前时间戳的最后一分钟内:
"lastHeartbeatTime": string
"lastStateTime": string
"lastEventTime": string
我的设备经常 ping 远程代理,MQTT Keep Alive 时间为 10 秒,所以我假设一分钟内最多 6 次心跳。
我的想法是,我想收集每个设备的可用性和正常运行时间指标以及警报的统计信息。
所有这些都有效,但我怀疑 Google 后端没有足够频繁地更新心跳、事件和状态时间戳,有时导致上述设置记录我的设备没有的统计数据起来,而事实上他们是。
我的问题是:
我的设备心跳时间在设备状态下的更新速度有多快?一分钟太短了吗?
您能推荐一种更好的方法来实现上述目标吗?这意味着什么?
仔细查看设备的 API 文档,状态似乎可以是 'stale by a few minutes'。是否有关于此最大值的提示?:
lastHeartbeatTime string (Timestamp format)
The last time an MQTT PINGREQ was received. This field
applies only to devices connecting through MQTT. MQTT clients usually
only send PINGREQ messages if the connection is idle, and no other
messages have been sent. Timestamps are periodically collected and
written to storage; they may be stale by a few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
Example: "2014-10-02T15:01:23.045123456Z".
lastEventTime string (Timestamp format)
The last time a telemetry event was received. Timestamps
are periodically collected and written to storage; they may be stale
by a few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
Example: "2014-10-02T15:01:23.045123456Z".
lastStateTime string (Timestamp format)
The last time a state event was received. Timestamps are
periodically collected and written to storage; they may be stale by a
few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
Example: "2014-10-02T15:01:23.045123456Z".
"lastHeartbeatTime" 是最后一次收到 PINGREQ 的时间,如果连接空闲并且没有发送其他消息,则会收到。 PINGREQ 是你的 MQTT Keep Alive 时间是 10s。因此,如果 10 秒内没有消息,您应该收到 PINGREQ。此信息应该在设备日志中可用。我建议将设备日志发送到 stacdriver 并使用日志来获取设备可用性和正常运行时间的统计信息。 Here 是如何做到这一点的示例。
我每分钟在下面执行一次 GET URL 以获取我的 IOT 注册表中所有设备的设备状态
GET https://cloudiot.googleapis.com/v1/{name=projects/*/locations/*/registries/*/devices/*}
获得 Device 后,我有兴趣确定以下字段是否在当前时间戳的最后一分钟内:
"lastHeartbeatTime": string
"lastStateTime": string
"lastEventTime": string
我的设备经常 ping 远程代理,MQTT Keep Alive 时间为 10 秒,所以我假设一分钟内最多 6 次心跳。
我的想法是,我想收集每个设备的可用性和正常运行时间指标以及警报的统计信息。
所有这些都有效,但我怀疑 Google 后端没有足够频繁地更新心跳、事件和状态时间戳,有时导致上述设置记录我的设备没有的统计数据起来,而事实上他们是。
我的问题是:
我的设备心跳时间在设备状态下的更新速度有多快?一分钟太短了吗?
您能推荐一种更好的方法来实现上述目标吗?这意味着什么?
仔细查看设备的 API 文档,状态似乎可以是 'stale by a few minutes'。是否有关于此最大值的提示?:
lastHeartbeatTime string (Timestamp format)
The last time an MQTT PINGREQ was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send PINGREQ messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
lastEventTime string (Timestamp format)
The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
lastStateTime string (Timestamp format)
The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
"lastHeartbeatTime" 是最后一次收到 PINGREQ 的时间,如果连接空闲并且没有发送其他消息,则会收到。 PINGREQ 是你的 MQTT Keep Alive 时间是 10s。因此,如果 10 秒内没有消息,您应该收到 PINGREQ。此信息应该在设备日志中可用。我建议将设备日志发送到 stacdriver 并使用日志来获取设备可用性和正常运行时间的统计信息。 Here 是如何做到这一点的示例。