# Get 'unique' results when uniqueness is defined by a different element

**URL:** <https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418>\
**Category:** Kibana\
**Created:** [December 5, 2017, 8:38pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418 "2017-12-05T20:38:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulAngus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulangus/32/25037_2.png) [@PaulAngus](https://discuss.elastic.co/u/PaulAngus)\
**Post date:** [December 5, 2017, 8:38pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/1 "2017-12-05T20:38:19Z")

</div>

I have results from test runs, every run has a testrun\_uuid, and every run creates 100s of result sets.  
I want to create a pie chart of results in a field (which is metadata about the test run and he same in every result set from a specific run), but want one count per testrun (ie using the test\_uuid to determine uniqueness of record)  
How should I go about this please... ?

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [December 6, 2017, 3:50pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/2 "2017-12-06T15:50:36Z")

</div>

Hi Paul,

I'm not quite clear on what you're asking. Are each of your result sets a pass or fail of a test? And you're trying to get the count of pass or fail for each test run? Maybe you could show a mock-up of the important fields of a few documents?

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![PaulAngus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulangus/32/25037_2.png) [@PaulAngus](https://discuss.elastic.co/u/PaulAngus)\
**Post date:** [December 7, 2017, 4:04pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/3 "2017-12-07T16:04:27Z")

</div>

thanks for the reply. here are some sample documents..

{  
"testrun\_uuid": "eea579b6-1512-45c2-ac36-18ccc14ef730",  
"type": "success",  
"name": "test\_02\_edit\_service\_offering",  
"time": 0.07197904586791992,  
"base\_cloudstack\_version": "4.9",  
"marvin\_hypervisor": "vmware",  
"hypervisor\_version": "5.5",  
"testrun\_date": "Thu Dec 7 05:01:24 UTC 2017",  
}

{  
"testrun\_uuid": "eea579b6-1512-45c2-ac36-18ccc14ef730",  
"type": "success",  
"name": "test\_09\_delete\_detached\_volume",  
"time": 25.823681116104126,  
"base\_cloudstack\_version": "4.9",  
"marvin\_hypervisor": "vmware",  
"hypervisor\_version": "5.5",  
"testrun\_date": "Thu Dec 7 05:01:24 UTC 2017"  
}

I would have hundreds of these documents per test run.

These two documents refer to the same test run (they have the same testrun\_uuid)  
I want to be able to do things like:

- show how many failures in each test run. for different hypervisors
- show coverage of hypervisor testing over last month (with each test run being a count of 1, rather than 100's)

many thanks

Paul Angus

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [December 8, 2017, 4:53pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/4 "2017-12-08T16:53:39Z")

</div>

There's a lot of possibilities for looking at that data. One example would be to create a new Visualization using a `Data Table`.  
In this example I first did a Terms aggregation on clientip, but you would pick either testrun\_uuid or marvin\_hypervisor.  
And then I did a Filter aggregation with response:200 and response:404, but you would use type:success and type:failure.  
Then in the results you would see each testrun\_uuid (or marvin\_hypervisor) with the pass and fail counts.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/e/1e59d5bcb638f79d108db5e589fb60b30c6b89d5.png)

Another way to get almost the same thing, is to split with a Terms aggregation on both fields like below. In this case I might see other response codes that I hadn't included in the filters above. But I also don't see the count where it's zero.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0c235ab7a41ebae538967ec2eb5ab28087992d32.png)

And you can do the same thing in a pie chart;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/a/fada15333463cb60a175eafad5acadfcfb96502b.png)

As you create visualizations that are useful, save them, and then add them to a dashboard.

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![PaulAngus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulangus/32/25037_2.png) [@PaulAngus](https://discuss.elastic.co/u/PaulAngus)\
**Post date:** [December 10, 2017, 8:16pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/5 "2017-12-10T20:16:42Z")

</div>

Thanks for the effort that you’re putting in here.  
Let me ask this a different way, if I wanted to know how many test runs I had done (ie how many unique uuids are there) – how would I get to that?

Kind regards,

Paul Angus

VP Technology  
[paul.angus@shapeblue.com](mailto:paul.angus@shapeblue.com)  
[www.shapeblue.com](http://www.shapeblue.com)

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [January 3, 2018, 10:54pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/6 "2018-01-03T22:54:22Z")

</div>

Sorry for the dealy. Holidays and all that.

It's easy to create a new Metric visualization and change the default Count metric to `Unique Count` and then select the field that you want the unique count of (like test run id).

Regards,  
Lee

---

<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:** [January 31, 2018, 10:54pm UTC](https://discuss.elastic.co/t/get-unique-results-when-uniqueness-is-defined-by-a-different-element/110418/7 "2018-01-31T22:54:39Z")

</div>

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