Value mapping for string not working

  • What Grafana version and what operating system are you using?
    Grafana 12.0.1 on Debian 12.11

  • What are you trying to achieve?
    I’m reading a true/false value from InfluxDB. It’s not boolean, but a string. I’d like to color-code this in state timeline, but it seems not to be recognized.

As you can see here, a false condition is present from around 29th of May on. When pointing the mouse at it, it turns into a lighter green, and the legend points out true and false, both in green.

  • How are you trying to achieve it?
    I tried to use several options in value mapping, but none seems to be applied:

  • What happened?
    True and False keep both shown as green.

  • What did you expect to happen?
    I expect “false” condition to be shown in different colour.

  • Can you copy/paste the configuration(s) that you are having problems with?

{
  "id": 10,
  "type": "state-timeline",
  "title": "Dachs 1",
  "gridPos": {
    "x": 15,
    "y": 7,
    "h": 3,
    "w": 3
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "lineWidth": 0,
        "fillOpacity": 70,
        "spanNulls": false,
        "insertNulls": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "axisPlacement": "auto"
      },
      "color": {
        "mode": "thresholds"
      },
      "mappings": [
        {
          "type": "value",
          "options": {
            "\"false\"": {
              "index": 0,
              "text": "test",
              "color": "red"
            },
            "false": {
              "index": 1,
              "text": "test",
              "color": "red"
            }
          }
        },
        {
          "type": "special",
          "options": {
            "match": "false",
            "result": {
              "color": "red",
              "text": "test",
              "index": 2
            }
          }
        }
      ],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          }
        ]
      }
    },
    "overrides": []
  },
  "pluginVersion": "12.0.1",
  "targets": [
    {
      "alias": "Dachs1",
      "datasource": {
        "type": "influxdb",
        "uid": "cfe3660c-5657-4b9f-8e3a-1334241171bb"
      },
      "groupBy": [],
      "measurement": "parser.0.BHKWs.Dachs1_laeuft",
      "orderByTime": "ASC",
      "policy": "default",
      "query": "SELECT \"value\" FROM \"parser.0.BHKWs.Dachs1_laeuft\" WHERE time > now() - 1h",
      "rawQuery": false,
      "refId": "A",
      "resultFormat": "time_series",
      "select": [
        [
          {
            "params": [
              "value"
            ],
            "type": "field"
          }
        ]
      ],
      "tags": []
    }
  ],
  "datasource": {
    "type": "influxdb",
    "uid": "cfe3660c-5657-4b9f-8e3a-1334241171bb"
  },
  "options": {
    "mergeValues": true,
    "showValue": "auto",
    "alignValue": "left",
    "rowHeight": 0.9,
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom"
    },
    "tooltip": {
      "mode": "single",
      "sort": "none",
      "hideZeros": false
    }
  }
}
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Not aware of, no.

  • Did you follow any online instructions? If so, what is the URL?
    I checked the other results on Grafana Community for “value mapping not working”, but without success.

Thanks for any hint!



i am simply value mappings and it is work for me please check your panel configuration.

This is what I’m trying to achieve, yes.
Well, it looks you did the exact same thing as I, and it works in your setup. However, just saying “check your configuration” is not of much help, as I did this extensively before opening a thread. No offense!

I’m still hoping for a hint what in my source data is different from yours (I guess this is where the problem begins). Is there a way to do a deeper check on source data, apart from table view? To find out which data type this is in InfluxDB, for example?

i am using postgresql using this i can achive your requirement.

Don’t ask why, but I fixed the issue by doing a transformation. “Convert field type”, Convert as “other”.


Thanks for your effort!

2 Likes