Gauge Panel Dynamic Threshold "Config from query" Transformation Problem With Base Color and Doesn't Allow Multiple Thresholds

Hello everyone.

Grafana Version Installed: v11.1.3 (beac3bdbcb) Open Source, Self-Hosted

What I’m trying to achieve: I have a gauge panel that I’m trying to set a dynamic threshold - the value of the threshold depends on a query. For example sake, suppose it’s the production of a factory, and there are daily quotas they have to produce. So the threshold base is red (not having achieved the daily quota) and the daily quota is green (so any value above the daily quota is green).

What have I tried: I created a database table with DATE and DAILYQUOTA values. To achieve the desired result, I’m using the Config from query results transformation. I have two querys on the panel - one retrieves the current production and the other one returns the daily quota. Therefore, I set “Config query” as the daily quota query and apply to the current production query. It works mostly as intended, however there are three main problems:

  1. By default, the config from query threshold values makes the base GREEN automatically. I can’t change the base color! I can achieve the inverse of the desired result by this means, the value starting green and then turning red. I can set the daily quota to GREEN, but can’t change the base to RED.
  2. So I though maybe I could add another threshold value at 0 setting the color to RED, so that even if the base is green, adding another threshold would force values between 0 and DAILYQUOTA to be red. However, I couldn’t add, at the same transformation, another threshold, so it’s only one threshold per transformation. This is another problem on itself, since the next step would be adding a “almost achieving daily quota” threshold, which won’t be possible.
  3. Adding another “Config from query” transformation to handle the other threshold overrides the first transformation, as if the last one has priority.

Ergo I have no alternative but to come to this forum and ask the community for help.
Screenshots:


Research I made previously to making this topic:
Barchart: Can't change dynamic threshold colors with 'config from query results' · Issue #56425 · grafana/grafana · GitHub ← thanissi’s comment on this issue is EXACTLY the same problem as I am having.
Problem with dynamic thresholds colors + config from Query transformation ← this gentleman is having a similar issue as mine, but in the time series panel.

Does any one of you have an idea or workaround this issue?
My idea is to insist on the gauge panel, but if there is no option, we’ll have to change to another visualization until Grafana updates.
Kind regards,

2 Likes

so daily you can skew the threshhold . are you using the date from date time picker or your query takes care of the current data based data? you dont look back in the past?

Thank you very much for the answer, yosiasz.

The idea is so that this dashboard becomes a “daily report” dashboard, so yes, the query uses the date time picker, you can choose any day, so ideally the threshold would be adjusted according to the selected date.

From all of my current research, I believe that the correct conclusion is that Grafana is not ready for this, and it’s currently a limitation. If you agree, I’ll make an issue specifically asking for this feature on the Grafana Github to get the dev’s attention.

Regarding your suggestion, yes, I could, theorically, manually adjust the daily threshold everyday. However, this would be troublesome and non-scalable since there are more than 20 variables and growing. However, this does give me an idea. Could I write a bot that, every day at 12:00 AM, manually edits the dashboard .json with the correct threshold for each variable, and then reload it? Then at least it would work for the day. Do you have experience with this?

As an experience Grafana user, would you do this a different way? Honestly, I’m kind of thinking about visualizing this in a different way, as two time series maybe, with the actual production of the day and the daily quota.

Kind regards,

1 Like

the out of the box gauge might not be able to do that but there are other ways.

business text
business chart plugins

so let’s say you have 6 presses and you want a gauge for each kinda thing?

Hello Solitcon, thank you for your answer.

Yes, I’m beginning to accept that using the default gauge may not be able to achieve the desired effect. I have now looked at the plugins you mentioned, however, they don’t seem to help me achieve the desired result. Could you help me with an initial idea, giving me some tips, and if possible, maybe some screenshots?

What did you mean by 6 presses, do you mean 6 “monitored things”? Yes, I’d like a “gauge” for each of the “monitored things”.

Kind regards,

1 Like

for some reason, it is not plotting them separately but you could use business text with plotly

image

Let me see why it does not lay them our properly

here is an example of Business Text with plotly

ok take a look at this js

var data = [
  {
    type: "indicator",
    mode: "gauge+number",
    value: 70,
    domain: { x: [0, 0.5], y: [0, 1] }, // Left half of the plot
    title: { text: "Gauge 1" }
  },
  {
    type: "indicator",
    mode: "gauge+number",
    value: 45,
    domain: { x: [0.5, 1], y: [0, 1] }, // Right half of the plot
    title: { text: "Gauge 2" }
  }
];

var layout = {
  width: 600,
  height: 400
};

Plotly.newPlot('myDiv', data, layout);

using this

1 Like

Yep, that seems to be it!
Haven’t tried it yet, but I believe I may achieve my desired results. I’ll edit the post when I do so.
I’m also going to start an issue on the grafana github so the devs can see if it’s a bug or a feature that needs fixing.
Kind regards and thank you all very much.

1 Like