I am running Influx 1.8 (and Grafana 7) on a Raspberry PI 4. Among other things, Influx receives datapoint from our electric vehicle when it drives or is getting charged. Influx receives data into various ‘measurements’, for example one measurement (with timestamp) each for latitude, longitude, odometer, speed, energy used, and charge added (while charging).
I would like to create a table of locations where I charged, with the total sum of energy charged at each respective locations, to be displayed in Grafana. The procedure I have in mind is
- In the charge_added measurement, look for zeros (because every charge starts at zero) and then take the previous value > 0 (which was the charge added the last time). Unfortunately, the charge_added measurement receives multiple values per charge process, one per minute.
- Get the lat/lng values with the same timestamp (rounded to 1min possibly) as the charge_added value.
- Sum up the charge_added values, grouped by lat/lng values.
- (possibly) label the lat/lng pairs in the table. Or use the map plugin and display the values on a map.
I think the main question is how to separate (group) the charge_added values by zero values, instead of time range. If I just “GROUP BY (time)” the charge_added, and then take last() or max(), I will miss multiple charge actions.