Hello everyone,
I still haven’t found an answer to my question on your community and that’s why I’m turning to you all.
I use grafana 10 and influxDB.
For a given time series query, I would like to display the first and last values on the time window being viewed, then subtract them from each other.
Then I’d like to be able to manipulate that value, like being able to divide it by the polling time (in hours).
Using the stat panel, I tried to
make two queries, one first and one last
to carry out a single query and use the calculation function to display the difference and make a transformation with the time, but it’s not working.
You are using InfluxQL. To do math between two queries, you can use an expression or a transformation. Expressions are usually $A+$B, but then you can do $C/100. From your screenshot, it looks like you tried a transformation.
Also, sometimes Grafana (or InfluxDB) require that the timestamps be aligned when trying to add 2 values. Not sure if this is the case with your data. Maybe you can use the reducer function “Last” to get them both to be at the same timestamp?
Thanks for your reply.
I’m used to doing calculations using expressions by aligning the times of the series using group by: time($interval).
However, I can’t do certain calculations, hence my initial question.
I would like to perform the following type of calculation on the observed time window:
A: request from sensor A select: field(raw value) + first
B: request from sensor A select: field(raw value) + last
expression : $A - $B
==> for a visual stat it outputs NaN whatever the calculation selected in the value option menu
then I’d like to be able to manipulate the result of the expression, for example :
expression / time window viewed with a unit display in l/h or similar but with a time in hours.