Kapacitor question from May 4, 2017 Training session

kapacitor
#1

Question: "An IoT use case: we have a ‘device’ measurement with a single tag ‘serialNo’. Every time an IoT device connects, we write “true” to the “request” field of this measurement, with the device serial number as a tag.

_How would a TICK script look like that does an HTTP POST once a device did NOT issue any request for X minutes? The device serial no should be part of the HTTP POST. I guess it uses the ‘deadman’ function."

Answer: The “deadman” function is the correct approach. Here is an example:

stream
    |from()
        .measurement('device')
        .groupBy(*)
    |deadman(0, 5m)
        .post('http://example.com')

This would alert once a device is inactive after 5m - but that can be changed in the above script by changing the 5m parameter

You can also check out the Training: Kapacitor on InfluxCloud