Weird behaviour with gauge with gauge visualization

I´m working with a SQL server, and I wanted to do some porcentages with the gauge tool. I did my querys to get 1 value per query, I reduced the query to an expression (max, mode strict) and I operated them with operation: math.

I´m new working with SQL and Grafana, and probably exists ways to improve my code.

Each gauge has 14 querys similar to:
declare @1d datetime
set @1d = DATEADD(day,-1, GETDATE())

CAST (TMDT as datetime) as time
WHERE TAG = ‘XX’ and tmdt < @1d

and retorn values, 14 reduce expressions and 1 math expression. 5 gauges.

All those operations worked well for some minutes, but I´m having problems when I reduce some of this values, getting me NaN values. I´m not sure if it´s happen because of a bug (If i do 3-4 querys, reduces, etc, it works fine, but with all operations that i need the wrong values happen), or i´m overcharging the tool, or any other error you can see.



Few questions here.

  1. Do you mean you have 14 gauges with 1 query each?
  2. Are you querying one tag per query. Is that the reaaon you have TAG = XXX

Instead of doing a lot of post processing of your data in grafana with transformations I would recommend you do it all in sql server query itself

Hi Yosiasz,

Thanks for your response.

  1. I have just 1 visual gauge per graphic, but I need to do some querys, reduces expressions and math expressions to get what I need. My skills on SQL are poor, because of that I do so many querys in Grafana.

  2. Yes, my “XXX” refers to diferent Tags. I simply did “copy and paste” my query. Actually I do 2 differents querys for the same Tag, with different range of time, to compare their values.

I´ve done some changes in the operations, and I saw if I reduce a math expression it works better than reduce a query. I don´t know if the problem is for working reducing querys, or simply for so many expressions in the same gauge.

Thanks for your time, J