Show devices whose last entry is older than two days

  • What Grafana version and what operating system are you using?
    V7.3.5

  • What are you trying to achieve?
    I’m using Graphana for some IoT devices and want to use it for maintenance reasons.
    So I’d like to show all Devices which aren’t sending data anymore for a longer period of time (2 days)

  • How are you trying to achieve it?
    I’m trying to get the last entry to the InfluxDB and filter it with time.
    This is my query:

SELECT data FROM
  (SELECT last("data_123") AS data FROM "autogen"."database" GROUP BY "device")
WHERE time < now()-2d GROUP BY "device"
  • What happened?
    The nested query doesn’t work. I get entries in the table from devices which sent data within the two days. The shown entry is the last one before the time filter (e.g 2 days and 5 mins)

  • What did you expect to happen?
    I expected that the inner query would only get the last updates from each device. With the second query I would filter out every device which sent an update whithin the two days

I would be glad, if somebody can help me. Thank you.

Can anyone help me with this?