Merge results from different sources (PostgreSQL and Influxdb)

Hello everyone,

I have a question that may be already asked, but i’m unable to find any results on the queries i explored for my specific needs.

The problem i have comes from the situation which requires to merge a result from 2 different datasources and display it as a single number. I’m required to calculate difference between a PostgreSQL query and InfluxDB query where both return a single value. The result displays them separate and i’m unable to perform any transformations to display them as a difference.

The best result i got is displaying result of both queries side by side.

The version of Grafana i’m using is 8.2.3

Hi,

Did you try to create both queries and then create a math calculation (if that’s what you need) as third query :
Query A : from source 1
Query B : from source 2
Calculation : A1 * A2

Hope it helps.

Good Luck

Hi, thank you for your reply.

I tried both the expression approach and manually creating the transformation and it did not work.

Here are some screenshots:

https://imagizer.imageshack.com/v2/1106x589q90/r/923/qzKwY0.png
https://imagizer.imageshack.com/v2/1106x589q90/r/922/DlEwP3.png

For the second image i also got the error that says: All queries must use the same datasource when trying to display all values in the widget, even the datasource is set to --Mixed–.

Hmmm…I would have expected the “Mixed” option to allow you to mix the datasources, but maybe there is a limitation somewhere that it not obvious.

You may have already tried this, but just in case…How about using Flux to query the PostgreSQL database? Maybe that is intended only for the InfluxDB audience and it would not work in Grafana?

I managed to pull it of with adding to both queries some placeholder data (any column name with both side same value) that would enable it to do the merge transformation first, which then allowed the calculation to be applied.