I have a simple counter which is stored in a InfluxDB. Now I would like to get the difference in the counter value between two points in time. So the result should only be a single value.
I tried the following query:
from(bucket: "influxdb")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "mqtt_consumer")
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["host"] == "telegraf-1-18-1")
|> filter(fn: (r) => r["topic"] == "shellies/shellyplug-s-DDE23E/relay/0/energy")
|> difference()
But this does not give the difference between the two counter values (actually I have no idea what the result is supposed to be).
Can anyone give me a hint on how to use difference correctly?