简体   繁体   中英

Creating pie chart by sum of values in Kibana

I have an index in Elasticsearch with data that looks like this:

    "_source": {
      "segments": [
        {
          "segmentType": "Indirect",
          "segmentCount": 100
        },
        {
          "segmentType": "Direct",
          "segmentCount": 20
        }
      ]
    }

I want to create a pie chart in Kibana where it takes the sum of segment count of each segment type. Currently, I only have the data above. So the pie chart should be split about: 83% for indirect and about 17% for direct. However, when I try to create a pie chart it is being split by 50% each. For slice size, I'm doing a sum of segment count and for split slices I'm doing a terms aggregation by the segment count field.

How can I achieve the result I want?

Old post but in case someone is still looking.

As far as I know it is not possible with the current version of Kibana (7.11) to create a pie chart using "sum of field value" to split slices, which is my understanding of what you were trying to do here.

In recent kibana versions the "Percentage Bar" visualization seems to be the way to present the percentage split you seek.

There is a related but old post (2017) on the elastic forum discussing 2 workaround options.https://discuss.elastic.co/t/simple-pie-chart-question/92749

  1. Ingesting the data (in these case it would be Indirect/Direct) as separate documents to be able to use the available aggregations.
  2. Creating an alternate visualization type, though I believe the more recent "Percentage bar" would fit the purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM