Making a Pie Chart for a boolean field with true/false labels

  • What Grafana version and what operating system are you using?
    Grafana v11.1.4 (2355de00c6) on Linux

  • What are you trying to achieve?
    I want a pie chart to represent a boolean custom field myPrefix.isMySuffix from an elasticsearch data source. I want the segments to be labelled true/false (or yes/no or 1/0).

  • How are you trying to achieve it?

  1. In the query, I am using the Metrics tab and have selected Metric: Count and Group By: Terms: myPrefix.isMySuffix.
  2. In [the options pane > Value options], I specified Show: All values and Fields: Count.
  • What happened?
    I get a pie chart where both segments are labelled ‘Count’.

  • What did you expect to happen?
    I expected that the labels would correspond to the values true/false (which are the values in my data for the field myPrefix.isMySuffix.

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

{
  "datasource": {
    "type": "elasticsearch",
    "uid": "REDACTED"
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": []
    },
    "overrides": []
  },
  "gridPos": {
    "h": 8,
    "w": 6,
    "x": 6,
    "y": 1
  },
  "id": 2,
  "options": {
    "reduceOptions": {
      "values": true,
      "calcs": [
        "count"
      ],
      "fields": "/^Count$/"
    },
    "pieType": "pie",
    "tooltip": {
      "mode": "single",
      "sort": "none"
    },
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom",
      "values": [
        "percent"
      ]
    },
    "displayLabels": [
      "name",
      "value"
    ]
  },
  "pluginVersion": "11.1.4",
  "targets": [
    {
      "alias": "",
      "bucketAggs": [
        {
          "field": "myPrefix.isMySuffix",
          "id": "2",
          "settings": {
            "min_doc_count": "0",
            "order": "desc",
            "orderBy": "_term",
            "size": "2"
          },
          "type": "terms"
        }
      ],
      "datasource": {
        "type": "elasticsearch",
        "uid": "REDACTED"
      },
      "hide": false,
      "metrics": [
        {
          "hide": false,
          "id": "1",
          "type": "count"
        }
      ],
      "query": "",
      "refId": "B",
      "timeField": "@timestamp"
    }
  ],
  "title": "REDACTED",
  "type": "piechart"
}
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors

  • Did you follow any online instructions? If so, what is the URL?
    No particular online instructions

can you please post sample es doc? obfuscate it if needed but keep doc structure intact

Sure. I imagined that was the configuration I shared above. Can you tell me how to obtain my es doc?

If you use ES query tool via cli or kibana ?

I’m using kibana