# Calculating a metric based off a pipeline aggregation

**URL:** <https://discuss.elastic.co/t/calculating-a-metric-based-off-a-pipeline-aggregation/102270>\
**Category:** Elasticsearch\
**Created:** [September 29, 2017, 2:08pm UTC](https://discuss.elastic.co/t/calculating-a-metric-based-off-a-pipeline-aggregation/102270 "2017-09-29T14:08:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael.Craig](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Michael.Craig](https://discuss.elastic.co/u/Michael.Craig)\
**Post date:** [September 29, 2017, 2:08pm UTC](https://discuss.elastic.co/t/calculating-a-metric-based-off-a-pipeline-aggregation/102270/1 "2017-09-29T14:08:17Z")

</div>

Hello,

We want to keep track of the record maximum daily searches. I have a metric visualization that does this with max bucket agg but I want to add extra functionality and I am finding it difficult.

Is it possible for me to calculate another metric (response time) which is restricted to the day of the max daily searches?

Some ideas, maybe this JSON 'keys' field would be useful (found in the elasticsearch response body)

```auto
{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 13,
    "successful": 13,
    "failed": 0
  },
  "hits": {
    "total": 6492,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "1": {
      "value": 526727,
      "keys": [
        "2017-09-26T00:00:00.000+01:00"
      ]
    },

   .....
}

```

To be concrete, I want to calculate the average response time for 2017/09/26 and for this metric to update (by changing the day it is querying documents from) if the maximum daily search changes.

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:** [October 27, 2017, 2:08pm UTC](https://discuss.elastic.co/t/calculating-a-metric-based-off-a-pipeline-aggregation/102270/2 "2017-10-27T14:08:58Z")

</div>

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