What Grafana version and what operating system are you using?
Grafana v9.5.5
What are you trying to achieve?
I have a panel with 3 PostgreSQL query results. I’ve aliased the results to “field1/2/3”. The queries are basically “select count(*) from table;”. I’m trying to sum the results of two queries. The panel type is “Stat”.
How are you trying to achieve it?
Using a “Add field from calculation” transform with the Binary Operation mode. I also added a transform before this one to convert the fields on numeric format for good measure but disabling this doesn’t change the results.
What happened?
Nothing happens when I select the two different fields on each side of the Operation. The transform only seems to work when I chose the SAME field on both sides of the operation.
What did you expect to happen?
I expected the transform to work. I should see a new result that is the sum.
Can you copy/paste the configuration(s) that you are having problems with?
No, it’s from my work install.
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
No errors.
Did you follow any online instructions? If so, what is the URL?
I can’t find any similar issues.
I did change the query types to “random walk” and immediately this started working as expected. I’m guessing the issue is with my SQL results.
The below is my setup that isn’t working as expected.
I’m not sure what you mean by different time stamps. If I refresh, the obvious expectation is that in real time the number are updated and the transform is applied. That said, I’m not familiar with checking “transformation debug option”. Where can I find that info?
Each of the 3 queries are coming from 3 separate databases. In the first image, the middle field is “field2” and the value of from the 2nd query, instead of using the configured alias “sum” and the sum’d value of fields 2 & 3, showing that the transform isn’t working unless I select the same query, “field”, for both sides of the operation.
Please help me to understand how I’m not being clear. I can’t pull queries from 3 separate DBs / 3 separate datasources in one query right? And even if I can, all these questions seem to be missing my main point.
Grafana lets me take 2 numbers from two queries and add them together but it’s not working. It shouldn’t matter if this is from one DB, or one hundred, or anything else. It lets me add 2 numbers together and it doesn’t let me know any considerations as to why this might not work as expected. I feel like this is either a bug or really poor design. That said, if there is something I can do to work around the issue so it performs as expected, I’d like to know.
Lesson: avoid transformation cause you will hit a wall or they might not work on some data sources but this limitation might not documented, use grafana for what it does best, visualization, the rest try to do it in the data source itself if at all possible.
My co-worker found a solution. He relayed “seems like data from the different datasources doesn’t have any common mapper or property. We can either go with add new mapper/property or ignore it.” I added the below above my “Add field from calculation” and it works now.