Is there any way to dynamically set multiple thresholds using multiple queries?

  • What Grafana version and what operating system are you using?

8.3 on Linux

  • What are you trying to achieve?

I’m trying to retrieve multiple configuration values from a Redis data source to be used in my gauges.

I’ve created a number of Gauge and Bar Gauge panels. Each panel should have multiple thresholds.

i.e. A “cell voltage” panel shows the real-time voltage for several cells, and the gauge should have 5 levels: Danger-Low, Warning-Low, Safe, Warning-High, Danger-High.

The cell voltages and threshold values are all stored in a Redis database. I want to be able to query the 4 threshold values from the database and use them to dynamically set the thresholds in the gauges.

The thresholds need to be dynamically loaded because this needs to work for various cell chemistries, which all have different operating voltages, currents, safe temperatures, etc.

  • How are you trying to achieve it?

The Redis Data Source plugin does not support MGET queries, so I can only GET the value from one key in each query. So I have to retrieve the 4 threshold values using 4 separate queries.

I tried creating multiple “Config from query results” transforms.

I also tried storing the threshold values in dashboard variables and using the dashboard variables as the threshold values.

Finally, I tried using multiple “Rows to fields” transforms.

  • What happened?

I can only create a single “Config from query results” transforms. Trying to add a second one just shows “No options available” in the dropdown.

I also tried using dashboard variables, but the threshold values don’t seem to allow variables.

Finally, the “Rows to fields” transforms aren’t working because it only uses the first query as the “field”. If I add multiple of these transforms, it always uses the same query as the “field” parameter.

Are these visualizations set to be viewed on demand with any time range or are they a snapshot in time like once a day at a specific time?

Thanks for responding. The gauge values need to update in real-time, either using streaming or with a 1s or 5s refresh.

The threshold values won’t change often within a redis database. So it’s okay if the thresholds are loaded only once on dashboard load. So if the threshold values can be put into variables at dashboard load, that would work fine.

I have a similar issue like ccbell (even though my data source is a MySQL-database, which is only updated once in several weeks, but this doesn’t make a big difference here, I guess):
I want to display hydrochemical data from a set of sampling points on a Geomap-panel with different chemical elements/compounds as a chosable variable and the colour thresholds adapting to the chosen variable (ideally with something like <75%,75-100%,100-125%,>125% of the limit defined by a guideline on water quality).
However, no need to target my case specifically here, I just want to highlight that ccbell’s request is also of relevance for other contexts. :slight_smile:

1 Like

I’ve been looking into this more and it seems there’s an even bigger issue with trying to do this; unless I’m mistaken, transforms can only ever set a single threshold. I managed to retrieve multiple Redis keys using a single CLI query, but I can still only set a single threshold. The only threshold option in the “Field” dropdown for any of the transforms is “Threshold1”.

Even when using CSV values for a config query, there’s no option to set more than one threshold.

the only way to do this dynamically is via provisioning maybe? but if you want to see things every few seconds that provisioning might not be an option