Can't use selectors for gauges

I can’t seem to get selectors to work with gauges. I am trying to create a panel of gauges that shows the current (most recent) value of a time series and the min and max.
You can see here that I’m using the same time series for all three dials, but have set one to last(), one to max() and one to min()


However I get the same value displayed by the gauge regardless of what I put in the selector, I can’t work out why or even what this the value that’s being shown is supposed to refer to!
Here you can see the time series plotted, the minimum temperature is about 29 degrees, it peaks at 46 and is currently 43. However all 3 gauges are showing 42?!

What’s going on here, am I supposed to configure this differently? I really can’t work out how!

Can you try removing all the items (“time” and “fill”) from the “GROUP BY” row? I think I know why you’re getting the result that you are, and this should fix the issue; can explain more if it actually works.

Thank you, yes that has worked. I didn’t realise you could completely remove the Group by options, I had tried fiddling with time intervals etc.

Note to anyone doing this: When you remove ‘time’ from the ‘Group by’ list it also removes any selectors you have set. I initially thought this hadn’t worked but then I noticed the selectors were missing, when I re-applied those then it was working.

Good to hear that this worked @trilbytim!

A few words on what I think was happening in your case: when you have a selector together with a GROUP BY clause in an Influx query, what Influx will do is apply the selector for each interval, and return a series of data points. Along with this, by default the Grafana queries are set up to generate data series for charts (not individual values), so that the $__interval variable in the GROUP BY close is very short (e.g. 1/1000th of your selected time range). So if you for example have a max() selector, the query will return the separate max values of each of the many intervals that you’re aggregating over.

So to begin with, the above is obviously not really what you wanted. But in addition to this, when you have a gauge panel that only displays a single value, and your query returns a series of values, Grafana itself will apply its own aggregation to convert that to a single value. That aggregation is configurable somewhere in the panel options, and I believe that the default is “average”.

Therefore in your initial situation you were simply seeing the averages of three time series that were all very similar to each other. Removing the GROUP BY ensures that in each of the series the selector will apply on the entire time range, rather than multiple short “micro-intervals”. Which is what you want. In this case the “Grafana aggregation” is basically a non-event, since each of the three queries just directly returns the values you need.

There is potential alternative approach, where you query the raw data from your database, and then do the aggregation in Grafana. You could go for this approach if you’re using a datasource that for some reason doesn’t support aggregation (or will stubbornly return a data series for some other reason). But in general I’d avoid doing it this way if possible - if only because of the larger volume of data you’ll need to query and transfer to the user’s browser.

1 Like