# Pie with specific metrics

**URL:** <https://discuss.elastic.co/t/pie-with-specific-metrics/191365>\
**Category:** Kibana\
**Created:** [July 19, 2019, 10:04am UTC](https://discuss.elastic.co/t/pie-with-specific-metrics/191365 "2019-07-19T10:04:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc1](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@luc1](https://discuss.elastic.co/u/luc1)\
**Post date:** [July 19, 2019, 10:04am UTC](https://discuss.elastic.co/t/pie-with-specific-metrics/191365/1 "2019-07-19T10:04:23Z")

</div>

Hello, I'm trying to do something tricky. In my JSON file that I parse, I have 4 counters.  
I want to have this result (I take the latest value of the counters by doing a sort on time) but in a pie where a slice is proportional to the number of the counters

 ![Screenshot%20(5)](https://us1.discourse-cdn.com/elastic/original/3X/b/8/b8bf0a2c16b92ee28ebd6787dc2951873daead2a.png)

If you see a way even hacky to do this I'm all ears

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [July 19, 2019, 7:50pm UTC](https://discuss.elastic.co/t/pie-with-specific-metrics/191365/2 "2019-07-19T19:50:02Z")

</div>

You won't be able to do this in Kibana with the current data model. The slices in a pie chart are based on buckets that contain different documents, not different values from the same document. You could do this with a different data model though.

Instead of putting all 4 count types in a single document, try creating a doc for each one. Imagine a document with the following fields: `@timestamp`, `alarmType`, and `count`.

A single document might look like this:

```auto
{
  "@timestamp": "2019-07-19T19:24:52.570Z",
  "alarmType": "critical",
  "count": 26
}

```

Now in your pie chart configuration you can create buckets with a terms aggregation on the `alarmType` field and configure a Top Hit metric on the `count` field. This will give you a pie chart where the slices are proportional to the latest count of each alarm type.

Here's an example visualization configuration using a terms agg and a top hit metric.

 ![01%20PM](https://us1.discourse-cdn.com/elastic/original/3X/1/0/1022f6633ddd3440d132e6d6b281b336c654f611.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 16, 2019, 7:50pm UTC](https://discuss.elastic.co/t/pie-with-specific-metrics/191365/3 "2019-08-16T19:50:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
