# How to take "average count on a field" as a metric?

**URL:** <https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601>\
**Category:** Kibana\
**Created:** [May 13, 2015, 8:07am UTC](https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601 "2015-05-13T08:07:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![huangyg11](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@huangyg11](https://discuss.elastic.co/u/huangyg11)\
**Post date:** [May 13, 2015, 8:07am UTC](https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601/1 "2015-05-13T08:07:30Z")

</div>

My records look like this:

```
( uri, uniqid)

```

Each records represents one database visit in a specific request on the uri. For example:

```
(/home, 1)
(/home, 1)
(/home, 2)

```

means A request on `/home` , and visit twice on database. And another request on `/home` visit only once on database.

Now, I want to know which uri has the most visits on database in average.

So, the metrics is the average visit times , and the bucket is the uri.

I don't know how to get it done on kibana. Anyone can help?

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [May 14, 2015, 5:39pm UTC](https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601/2 "2015-05-14T17:39:54Z")

</div>

This sounds like something we will be supporting once Elasticsearch 2.0 comes out. The current documentation for this unreleased feature [here](https://github.com/elastic/elasticsearch/blob/master/docs/reference/aggregations/reducer/avg-bucket-aggregation.asciidoc). Does it sound like what you are looking for?

---

<div class="post-metadata">

**Author:** ![huangyg11](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@huangyg11](https://discuss.elastic.co/u/huangyg11)\
**Post date:** [May 15, 2015, 5:53am UTC](https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601/3 "2015-05-15T05:53:37Z")

</div>

Not actually.

For each uri, the score ( avg. DB visiting times) can be represented as :

```
count of (uri) / uniq count of (uri, uniqid)

```

I want to sort on the score.

---

<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 6, 2017, 2:19pm UTC](https://discuss.elastic.co/t/how-to-take-average-count-on-a-field-as-a-metric/601/4 "2017-07-06T14:19:28Z")

</div>


