# Buckets\_path not resolving to correct metric

**URL:** <https://discuss.elastic.co/t/buckets-path-not-resolving-to-correct-metric/155204>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 4:26pm UTC](https://discuss.elastic.co/t/buckets-path-not-resolving-to-correct-metric/155204 "2018-11-02T16:26:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Sidana](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@Vikas\_Sidana](https://discuss.elastic.co/u/Vikas_Sidana)\
**Post date:** [November 2, 2018, 4:26pm UTC](https://discuss.elastic.co/t/buckets-path-not-resolving-to-correct-metric/155204/1 "2018-11-02T16:26:10Z")

</div>

Using mutiple filter aggregation and then using buckets\_path to compare the metrics in bucket. But it's not working. Here's the JSON I wrote:

```auto
GET /test/_search?pretty
{
  "query": {
    "bool": {
      "filter": {
        "range": {
          "last_check": {
            "from": "now-300d",
            "to": "now"
          }
        }
      }
    }
  },
  "aggs": {
    "group_by_server": {
      "terms": {
        "field": "sc_name",
        "size": 10000
      },
      "aggs": {
        "time_range": {
          "filters": {
            "filters": {
              "last_15_min": {
                "range": {
                  "last_check": {
                    "from": "now-15m",
                    "to": "now"
                  }
                }
              }, 
              "last_2_months": {
                "range": {
                  "last_check": {
                    "from": "now-300d",
                    "to": "now"
                  }
                }
              }
            }
          }, 
          "aggs": {
            "avg_memory": {
              "avg": {
                "field": "memory"
              }
            }
          }
        },
        "should_we_consider": {
          "bucket_selector": {
            "buckets_path": {
              "last_15_min": "time_range>last_15_min>avg_memory",
              "last_2mon": "time_range>last_2_months>avg_memory"
            },
            "script": "params.last_15_min > 0"
          }
        }
      }   
    }
  }
}

```

Output I get is:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "No aggregation [last_15_min] found for path [time_range>last_15_min>avg_memory]"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "imi2",
        "node": "KQZiCLqSR0CmHHYZkxNHMg",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "No aggregation [last_15_min] found for path [time_range>last_15_min>avg_memory]"
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "No aggregation [last_15_min] found for path [time_range>last_15_min>avg_memory]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "No aggregation [last_15_min] found for path [time_range>last_15_min>avg_memory]"
      }
    }
  },
  "status": 400
}

```

---

<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:** [November 30, 2018, 4:26pm UTC](https://discuss.elastic.co/t/buckets-path-not-resolving-to-correct-metric/155204/2 "2018-11-30T16:26:15Z")

</div>

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