Search code examples
google-cloud-platformstackdrivergoogle-cloud-iot

Google IOT per device heartbeat alert using Stackdriver


I'd like to alert on the lack of a heartbeat (or 0 bytes received) from any one of large number of Google IOT core devices. I can't seem to do this in Stackdriver. It instead appears to let me alert on the entire device registry which does not give me what I'm looking for (How would I know that a particular device is disconnected?)

So how does one go about doing this?


Solution

  • I have no idea why this question was downvoted as 'too broad'.

    The truth is Google IOT doesn't have per device alerting, but instead offers only alerting on an entire device registry. If this is not true, please reply to this post. The page that clearly states this is here:

    Cloud IoT Core exports usage metrics that can be monitored programmatically or accessed via Stackdriver Monitoring. These metrics are aggregated at the device registry level. You can use Stackdriver to create dashboards or set up alerts.

    The importance of having per device alerting is built into the promise assumed in this statement:

    Operational information about the health and functioning of devices is important to ensure that your data-gathering fabric is healthy and performing well. Devices might be located in harsh environments or in hard-to-access locations. Monitoring operational intelligence for your IoT devices is key to preserving the business-relevant data stream.

    So its not easy today to get an alert if one among many, globally dispersed devices, loses connectivity. One needs to build that, and depending on what one is trying to do, it would entail different solutions.

    In my case I wanted to alert if the last heartbeat time or last event state publish was older than 5 minutes. For this I need to run a looping function that scans the device registry and performs this operation regularly. The usage of this API is outlined in this other SO post: Google iot core connection status