# Best practice to aggregate by issue status

**URL:** https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596
**Category:** Kibana
**Tags:** lens
**Created:** [January 8, 2024, 2:41pm UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596 "2024-01-08T14:41:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lizozom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lizozom/32/114932_2.png) [@lizozom](https://discuss.elastic.co/u/lizozom)
#### Post date: [January 8, 2024, 2:41pm UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/1 "2024-01-08T14:41:12Z")

</div>

I have an index that stores logs of issue status changes (imaging something like GH issues). An issue can be either open or closed.

I want to show a metric of how many issues are currently open or closed.

What would be the appropriate way to create such a visualization?

i.e. within the given time frame:

- 20 issues were closed
- 10 issues remain open

Thank you

---

<div class="post-metadata">

### Author: ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)
#### Post date: [January 8, 2024, 8:47pm UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/2 "2024-01-08T20:47:41Z")

</div>

Hello @lizozom,

A [metric visualization](https://www.elastic.co/guide/en/kibana/8.11/add-aggregation-based-visualization-panels.html) would be good.

Example (in this case 200, 404, 503), [count aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-aggregations-metrics-valuecount-aggregation.html).

 ![Screen Shot 2024-01-08 at 3.39.22 PM](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8c4608bf204348a8bf33afe54c3096d07b9b0488.jpeg)

Then you can add a filter specifically for open or closed.

Example: `status.keyword : "open"`

---

<div class="post-metadata">

### Author: ![lizozom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lizozom/32/114932_2.png) [@lizozom](https://discuss.elastic.co/u/lizozom)
#### Post date: [January 9, 2024, 9:10am UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/3 "2024-01-09T09:10:53Z")

</div>

Let me clarify my use case:

When the issue is opened, a log is added saying issue #1234 is opened on the 01-01-2024 08:00:00.  
Then when the issue is closed, a log is added, saying issue #1234 is closed on the 01-01-2024 10:00:00.

If I use a simple metric visualization, I would get +1 on the open AND on the closed counters. I want the issue to be either open OR closed, so that it's not counted twice.

I used a Transform to aggregate the data by issue ID, but I was wondering if there was a more convenient way of doing this.

---

<div class="post-metadata">

### Author: ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)
#### Post date: [January 9, 2024, 11:44am UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/4 "2024-01-09T11:44:10Z")

</div>

Hi @lizozom ,

the only alternative to the `Transform` approach I can think of is building 2 distinct metric visualisations with raw documents:

- first one for the `Still open` issues will have the `count(kql='status.keyword: "open"') - count(kql='status.keyword: "closed"')` formula
- second one for the `Closed ones` will have a count with the `'status.keyword: "closed"'` filter on it.

---

<div class="post-metadata">

### Author: ![lizozom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lizozom/32/114932_2.png) [@lizozom](https://discuss.elastic.co/u/lizozom)
#### Post date: [January 9, 2024, 1:15pm UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/5 "2024-01-09T13:15:33Z")

</div>

The `Transform` approach sounds good then!  
Good they were added.

Thanks!

---

<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: [February 6, 2024, 1:16pm UTC](https://discuss.elastic.co/t/best-practice-to-aggregate-by-issue-status/350596/6 "2024-02-06T13:16:08Z")

</div>

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