Quantcast
Channel: InfluxDB - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 203

GROUP BY time - want to look backwards / handling timing deviations

$
0
0

Dear experts,
I’m monitoring a bunch of sensors with Grafana from an InfluxDB database.
Besides the actual sensor readings I also want to monitor if the sensors are sending regularly new values, since the sensors use a wireless connection that may have problems.
Since I know the interval at which the sensors are supposed to send data, my idea was to count the sensor entries in the database for a given time frame.
More hands on: when a sensor is supposed to send a new value each 5 min I expect 12 sensor values per hour.

I used the following query in Grafana in a time series visualization:
SELECT count("temperature") FROM "room_temp" WHERE ("device_id"::tag = 'xyz') GROUP BY time(60m)

That almost gives me what I need. Anyhow, there are two issues:

  • The GROUP BY TIME function looks ahead.
    Example: I get a data-point from that query each hour (8:00, 9:00, 10:00, …). Let’s assume it is 11:36. From the start of the 11:00 data-point I have 7 seven sensor values (one each 5 min), hence the value for the 11:00 data-point is 7, which gives the impression that I haven’t received enough sensor readings, since I expect 12/ hour. What I want to achieve is to look 1 h backwards.
    Because only when I look back I have now an idea about how regularly a sensor is sending data. If look ahead I can only tell it at the end of each hour.
    Is there a way to group by the last hour?

  • I think this one is more tricky. The time-base of some sensors is not ultra precise.
    Real world example:
    I received a sensor value at 8:59:26. Since the actual time between sensor values is 5:06 min, the 12th value for that hour is received at 10:00:38. Hence during that 1 hour interval only 11 values are received. Looks like 1 lost data value, but is just a bit of missing timing precision.
    I tried to increase the group by interval to 61,5 min. But besides the fact, that this gives a bit strange data points (no longer one each hour at the full hour) I have now from time to time 13 sensor values in an interval :see_no_evil:.
    Any idea of a good way to prevent that?

Christian

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 203

Trending Articles