Kibana - calculate average bucket over multi layer data

Hi,
I'm able to calculate average bucket score over one layer of data, but not on two lever hierarchy data.
Example:

A-parent-group m-group t-team 1
A-parent-group m-group t-team 4
A-parent-group n-group p-team 45
A-parent-group n-group p-team 34
A-parent-group n-group k-team 3

In above data, the average at group level can be calculated using bucketing at team level and I can get accurate results as
m-group: 2.5
n-group: 21.25

Now while I try to calculate average avg at parent group.
The bucketing at group level will give wrong output as: 29.83
but actually it should be 11.87

Pls help

@elastic_team Please help!

I found a way out by using aggregation query

GET /_search
{
  agg:
    agg-a
       agg-b
         agg-c
            agg-avg
       bucket-agg { name: bkt-aggc,
           { aggc > agg-avg } }
    bucket-agg { name: bkt-aggb,
         {aggb > bkt-aggc } }
  bucket-agg { name: bkt-agga,
      {agga > aggb} }
}

Sorry, but writing pseudo query here, will update it sometime later.

The key is first calculate aggregation at team level (lowest level)
Then wrap it with bucket average, which is at group level (next higher level)
and then wrap it again with bucket average, the A-parent-group (top level)

This way we could achieve bucket averages at any number of levels. :grinning: :
This way I'm able to catch the aggregate numbers but still not sure how to build visualization using this. If vega is only way, I will need to spend some more time on visualization part :construction_worker_man:

1 Like

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