Sibling aggregations : Average Bucket Query

Hi,
I’m actually using Kibana to be able to query from my Elasticsearch instance, then i decided to add Grafana in order to have Graph panels and Alerting.
Most of my queries are using average bucket aggregation ( supported in Kibana ) and i’m struggling to implement this type of sibling aggregation using Elasticsearch Datasource in grafana.
Here’s an exemple of a query i use in kibana in order to calculate the average value of a specified metric (response.transferSize) in a sibling aggregation.

  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        },
        {
          "range": {
            "startedDateTime": {
              "gte": 1570610420950,
              "lte": 1570611320950,
              "format": "epoch_millis"
            }
          }
        }
      ],
      "must_not": []
    }
  },
  "size": 0,
  "_source": {
    "excludes": []
  },
  "aggs": {
    "2": {
      "terms": {
        "field": "identificationTag",
        "size": 10000,
        "order": {
          "2-orderAgg": "desc"
        }
      },
      "aggs": {
        "1": {
          "avg_bucket": {
            "buckets_path": "1-bucket>1-metric"
          }
        },
        "2-orderAgg": {
          "avg": {
            "field": "response.transferSize"
          }
        },
        "1-bucket": {
          "terms": {
            "field": "run.page._meta.id_run",
            "size": 1000,
            "order": {
              "_count": "desc"
            }
          },
          "aggs": {
            "1-metric": {
              "avg": {
                "field": "response.transferSize"
              }
            }
          }
        }
      }
    }
  }
}

How do I implement it in Grafana using Elasticsearch Datasource ?
Thanks

AFAIK it is not currently supported but it would be an excellent feature request (in order to make the same things than Kibana with ES) :slight_smile: