Hello,
I am testing InfluxDB3 Enterprise (Alpha version) and I am struggling to get the correct calculation of some IOT device metrics through Grafana (and InfluxQL).
I was previously able to get the right calculation in InfluxDB 2, but unfortunately Flux language has been dropped and now I am learning once again from scratch.
Here is the scenario:
I have some Tasmota devices which store historical Energy data values. The metric increases every day/hour/minute based on the Energy consumption of the connected device. Unfortunately, from time to time the metric resets or decreases to a previous stored value, for instance: today the value stored is 100, tomorrow is 102 (2 kWh consumed in that day), the day after for some reasons it decrease or reset.
In Grafana I use the “non_negative_difference” of last value grouped by 1 minute. In this way I can get the energy consumed every minute. But I would like to aggregate by day, week, month…
This is the query:
SELECT non_negative_difference(last("Total")) FROM "tasmota" WHERE ("room"::tag = 'bathroom' AND "device"::tag = 'washer') AND $timeFilter GROUP BY time(1m) fill(none)
How can I get the total energy consumed by week, with week starting from Monday?
I also tried this query:
SELECT non_negative_difference(last("Total")) FROM "tasmota" WHERE ("room"::tag = 'bathroom' AND "device"::tag = 'lavatrice') AND $timeFilter GROUP BY time(1w, 4d) fill(none)
The latter calculates the total weekly energy from Monday, but if for any reason the IOT metric “Total” decreases its value during the week, no value is being shown because of the “non_negative_difference” takes control of calculation.
This happens this week:
Probably I missed something, but with Flux this task was pretty easy to accomplish.
Thank you.