# Derived Unique values from the unique values

**URL:** https://discuss.elastic.co/t/derived-unique-values-from-the-unique-values/53429
**Category:** Elasticsearch
**Created:** [June 21, 2016, 6:59am UTC](https://discuss.elastic.co/t/derived-unique-values-from-the-unique-values/53429 "2016-06-21T06:59:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)
#### Post date: [June 21, 2016, 6:59am UTC](https://discuss.elastic.co/t/derived-unique-values-from-the-unique-values/53429/1 "2016-06-21T06:59:34Z")

</div>

I have a csv with a system-ip (String) in 56th field and Errors in the 12th field. When ever my ip struct with an error its writing a error log and I am parsing it to elastic search. Now I want to see which ip is getting which error and how many times.

`{ "size": 0, "aggs" : { "langs" : { "terms" : { "field" : "column56" } } }}`  
From this I can get all unique ip. Now I want ito know in that ip how many errors (12th filed) I get and count of that error... Thanks for any help

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [June 21, 2016, 4:24pm UTC](https://discuss.elastic.co/t/derived-unique-values-from-the-unique-values/53429/2 "2016-06-21T16:24:51Z")

</div>

You can embed another terms aggregation inside the first one, which will give you a list of errors-per-IP (and counts).

```auto
{
  "size": 0,
  "aggs" : {
    "langs" : {
      "terms" : { "field" : "column56" },
      "aggs": {
         "errors": {
            "terms" : { "field" : "column12" }
         }
      }
    }
  }
} 

```

---

<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: [July 5, 2017, 10:41pm UTC](https://discuss.elastic.co/t/derived-unique-values-from-the-unique-values/53429/3 "2017-07-05T22:41:41Z")

</div>


