View anything in Vega + Kibana that is not a `doc_count`

774 views Asked by At

I am currently developing Vega visualizations in Kibana. The following image shows the doc_count of indices, which is essentially the default script that Kibana offers in Amazon ELK. Whilst it is simpler to develop in https://vega.github.io/editor, the idea is ultimately to visualize Elasticsearch data in dashboards.

Document count over time

There are a few examples integrating Vega with Kibana, but in the end I've only found ones that show the doc_count of an index. For example, https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana

At the moment, I'm looking at https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-search.html for details on custom search queries so as to return something other than doc_count in the aggregated buckets.

1

There are 1 answers

0
Daniel Robinson On BEST ANSWER

So I found in https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-aggregations-bucket-filter-aggregation.html that one just needs to add a sub-aggregation, or another aggregation inside the bucket aggregation to get a value other than doc_count in the buckets.

Use this as an example:

POST /sales/_search?size=0
{
    "aggs" : {
        "sales_over_time" : {
            "date_histogram" : {
                "field" : "date",
                "calendar_interval" : "month"
            },
            "aggs" : {
                "avg_price" : { "avg" : { "field" : "price" } }
            }
        }
    }
}