Search code examples
formulainfluxdbgrafana

Grafana: How to implement math formula in query


I am trying to create a influxdb query which selects pressure values and apply a math function on them. I found out how how to apply simple calculations like /100 (see the following screenshot) which works. enter image description here

But I want to calculate the altitude from this pressure values. The formula for this is the following:

enter image description here

Where p is the pressure (the query value in my case) and p0 is a constant. So now my question is how can I apply the formula for altitude to my pres value ? Or is it not possible because I can only do simple operations like the /100 with the math block ?


Solution

  • As far as I'm aware there is not currently any support in InfluxDB for exponents, which means that your equation can't be calculated.

    There is an open issue in github (actually 2, a "feature collection" and an individual issue) for adding this as well as a host of other enhancements, but no timeline for when it might happen.

    Feature Collection #5930

    Individual Issue #659

    The simplest suggestion I have right now would be to calculate the altitude within your collector and store that in the database along with pressure.

    Another alternative would be to switch to Graphite, which does support pow(), scale() & offset() functions and thus should be able to perform that calculation.