It represents the total of electric power consumption from my smart meter. I would like to get the difference between the last two values and make a graph in grafana.
8268.219 - 8268.218 = 0.001
How would you do that. Is there a nice query I can use in grafana or do I have to create a InfluxDB Task and make the calculation there?
@Manuel, if you’re using Flux in Grafana, this would be pretty simple. You’d just use the difference() function to calculate the difference between subsequent points, then use the last() selector function to return only the last record.
Hell Scott
Thank you very much for your quick answer. Well, for a rookie this seems to be a InfluxDB task, right? I will follow this instruction and create a task option, a data source and a data transformation.
This functions are also available for Version 1.7.8?
Flux is InfluxData’s new functional data query/scripting language. This is just a Flux query, not a task. And yes, Flux is packaged with 1.7.8, you just need to enable it in your InfluxDB config.
Happy to help. And no worries. I should’ve given a little more context to Flux up front. If you have any other questions, feel free to send them my way.
Ok, and just to make sure – openhab_db is the database and TotalRate is the retention policy within that database? When using Flux with InfluxDB 1.7.x, Flux expects the bucket to be a combination of the database and the retention policy: db_name/rp_name.
You may also need to deselect basic auth. InfluxDB supports basic auth, but Flux doesn’t currently handle any of the authorizations. This may not make a difference. I’m not sure.
Hello Scott
Hm…this might be the point. As you can see in my code snippet openhab_db is the database, that’s right. TotalRate is a time series and represents the total of electric power consumption from my smart meter in kWh.
> use openhab_db
Using database openhab_db
> show retention policies
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 0s 168h0m0s 1 true
My retention policy is called autogen. So the bucket must be openhab_db/autogen? If I use this I still get
Data source connected, but has no data. Verify the "bucket" field and make sure the bucket has data.
Will try to enable logging/debugging in influxdb to see more when I make a Save & Test.
Yeah, with your setup, your bucket name would be openhab_db/autogen. I’m not really sure why it wouldn’t detect any data in the bucket. You may also try walking through the process here.
Hello Scott
Thank you for your answer. I followed your instruction and also installed yarn although I don’t know what exactly what I’m doing. I’m still getting the same error and I can’t connect to openhab_db/autogen.