How to do even the simplest calculation with a few independent query results

I need to do the simplest calculation in Grafana and just don’t manage to find a way how to do this.
I want to calculate and show x where x = a / ( a + b) and where a and b are single numbers and the result of independent queries. x is a single number as well.
I have looked at the built in transform function but that seems to allow only to do calculations within the results of a single query.

I have managed to do very nice things already with grafana, but surprisingly, it seems I am sometimes really struggling to get the most basic things done.
So I hope to find an answer here on this seemingly very simple problem.

FYI Grafana v8.3.4

What is your datasource? Could you build a 3rd query to do the A/B calculation and then have Grafana display that new query?

Hi, the datasource is GraphQL.

My query (in a single stat window for example) looks like
m1:get(from:$__from, to: $__to, type: “range”, variable:“AV_CombTimeSec”){value}

This gives me a single number, and this number I would like to use in a calculation with results from other queries.

I do not see or know how I can add another query and make a calculation. Do you have an example or suggestion ?


Sorry, I don’t have an intimate familiarity with the GraphQL plugin and how cases like this need to be treated. It may be worth trying to reach out to the developer on Github if nobody on this forum can help.

1 Like