Elasticsearch bucket script aggregation in Kibana

I am trying to create the visualization in Kibana, to show the count of orders whose average api time is less than 60 Sec.
Below are the sample ES index documents:

order_id    time    api
1           50.0    /login
1           43.1    /XXXXX
1           41.5    /XXXXX
1           48.7    /XXXXX
2           31.2    /XXXXX  
2           54.6    /XXXXX  
3           84.0    /XXXXX  
3           41.0    /XXXXX  
3           109.32  /XXXXX  

Elasticsearch query to find the count of orders whose average api times are less than 60 seconds.

GET my-index-0000001/_search
{
  "size": 0, 
  "aggs": {
    "average_by_id": {
      "terms": {
        "field": "order_id.keyword",
        "size": 1000
      },
      "aggs": {
        "avg_api_time": {
          "avg": {
            "field": "time"
          }
        },
        "order_bucket_filter": {
          "bucket_selector": {
            "buckets_path": {
              "avgApiTime": "avg_api_time"
            },
            "script": "params.avgApiTime < 60"
          }
        }
      }
    },
    "mybucketcount":{
      "stats_bucket": {
        "buckets_path":"average_by_id._count"
      }
    }
  }
}

How can we visualize the count in the Kibana please. Thank you!

Hello,

Sadly the bucket selector aggregation is not available in Kibana yet: https://github.com/elastic/kibana/issues/11167
You could probably build your own visualization with Vega that returns that.

Could you provide me the pointer / links to build the bucket selector aggregation visualization with Vega. Thank you!

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