Threshold colors in stat panel about diskpace usage not working

What Grafana version and what operating system are you using?
Grafana v8.2.2 (6232fe07c0) and Debian 11 (bullseye)

What are you trying to achieve?
I want colors established by threshold change properly as it should.

How are you trying to achieve it?
Asking in grafana community…

What happened?
I’m using Grafana with Zabbix (5.4.6) data source and configured three Stat Panels which monitor from left to right the “Used space” in GB, the “Used space (%)” and the “Total space” in GB, from several Linux machines (mostly CentOS and Debian), as you can see in the following screenshot. The problematic one is the first one “Used space”, the others work fine.

The panels show the values as they should and they work perfectly except for one detail. As you may see in the following screenshot I configured three simple thresholds for the “Used space” (in GB) panel in order to make the background change its color when it reaches each specified % value. Now it’s just red and that’s wrong, because in the case of this machine 17.9GB of 312GB it’s just 6%, then it should be green…

The “Used space (%)” panel works as it should, in this example shows 6% as green and in other machines when reaches more than 50% the color turns yellow and when 80% the color turns red as expected. The only noticeable difference is that I’m using “Thresholds mode” as “Absolute”. In the previous screenshot you can see I’m using “Percentage” mode, already tried to use “Absolute” mode too and didn’t work.

I have a second machine to show as an example of what is happening. The “Used space (%)” panel works as intended, but the first panel “Used space” don’t. The color is yellow when it should be red because is over 80%.

What am I doing wrong? I know this might be a bit stupid post for complaining about a tiny detail, but our customers have access to their own machines dashboards and they noticed and asked us to correct the colors in “Used space” panel, because they like to see green as low used space, yellow as half storage occupied and red as high used space.

If there is anything else I can provide, just let me know.

What did you expect to happen?
As already stated, when used space (in GB) panel reaches 50% background should turn yellow and when it reaches 80% it should turn red.

Can you copy/paste the configuration(s) that you are having problems with?
Here I paste the configuration about “Used space” and “Used space (%)” panels:

      "title": "Used space",
      "type": "stat"
    },
    {
      "datasource": "Zabbix",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "decimals": 0,
          "mappings": [],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 50
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 4,
        "x": 10,
        "y": 19
      },
      "hideTimeOverride": false,
      "id": 99,
      "links": [],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "8.2.2",
      "targets": [
        {
          "application": {
            "filter": "/Filesystem./"
          },
          "functions": [],
          "group": {
            "filter": "$Group"
          },
          "host": {
            "filter": "$Host"
          },
          "item": {
            "filter": "/: Space utilization"
          },
          "itemTag": {
            "filter": "Application: Filesystem /"
          },
          "options": {
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "A",
          "resultFormat": "time_series",
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "trigger": {
            "filter": ""
          },
          "triggers": {
            "acknowledged": 2,
            "count": true,
            "minSeverity": 3
          }
        }
      ],
      "title": "Used space (%)",
      "transformations": [],
      "type": "stat"
    },
    {
      "datasource": null,
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 3,
        "w": 10,
        "x": 14,
        "y": 19
      },
      "id": 100,
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "value"
      },
      "pluginVersion": "8.2.2",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "functions": [],
          "group": {
            "filter": "$Group"
          },
          "hide": false,
          "host": {
            "filter": "$Host"
          },
          "item": {
            "filter": "/: Total space"
          },
          "itemTag": {
            "filter": "Application: Filesystem /"
          },
          "options": {
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "B",
          "resultFormat": "time_series",
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "trigger": {
            "filter": ""
          },
          "triggers": {
            "acknowledged": 2,
            "count": true,
            "minSeverity": 3
          }
        }
      ],

I think I didn’t miss any line about config.

Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
No errors are displayed, this is most likely a configuration problem.

I’ve just found the following lines in “/var/log/grafana/grafana.log”, but I think this lines aren’t related to my problem (I have anonymized the lines because they include sensitive data like public IPs or domains):

2024-03-25T12:18:14+0100 lvl=eror msg="Metric request error" logger=context userId=1 orgId=1 uname=admin error="failed to query data: Failed to query data: rpc error: code = Canceled desc = context canceled" remote_addr=ANONYMOUS_IP
t=2024-03-25T12:18:14+0100 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/ds/query status=500 remote_addr=ANONYMOUS_IP time_ms=19 size=34 referer="https://ANONYMOUS_GRAFANA_DOMAIN/d/xnigio0Sz/pruebas-master-panel?orgId=1&var-Group=ANONYMOUS_GROUP&var-Host=ANONYMOUS_HOSTNAME&editPanel=102"

Did you follow any online instructions? If so, what is the URL?
Yes, I tried to follow several online guides (I didn’t find guides about a Stat panel like my case, only was able to find guides about thresholds colors not working but in bar charts, time series,…), official grafana guides about how to configure thresholds but I did not find a solution.

1 Like

if you have a disk that is 1024gb

then for your red yellow green scenario, you would need to configure the thresholds as follows:

you cant use percentage, because these are absolute values:

this is a bit of a pain, because you need to know what your thresholds are before you can configure them, and they might be different for each disk.

What is your data source? Please post sample data

Hi, thanks for replying!

Your solution indeed works, but I intend to create the perfect template so every time a new machine is added I upload the template and everything should be working without manual intervention.

I already have many machines being monitored by Grafana, if I have to change one by one the thresholds depending on how much diskspace they have, it can be a pain.

Do you know any other way to monitor diskspace in a similar way (if possible) without manually modifying the dashboard on each machine?

Thanks for replying!

What do you mean by sample data?

My data source is Zabbix (5.4.6), I don’t know if this is what you need:

1 Like

Hey, just wanted to drop a quick reminder about the message I sent almost a week ago. Hope all is well with you and you can take a look when you get a chance! Thanks!

If you don’t know a way to create an automatic template for any machine it’s ok, I will close the post