Kibana multi-line chart with legend help

I would like to draw a multi-line chart with legend from a query with format
like the following:

 "aggregations": {
    "time_buckets": {
      "buckets": [
        {
          "key_as_string": "2022-02-22T00:00:00.000Z",
          "key": 1645488000000,
          "doc_count": 18478,
          "count": {
            "doc_count": 25570,
            "categories_count": {
              "doc_count_error_upper_bound": 0,
              "sum_other_doc_count": 0,
              "buckets": [
                {
                  "key": 3,
                  "doc_count": 4218
                },
                {
                  "key": 1,
                  "doc_count": 3398
                },
                {
                  "key": 5,
                  "doc_count": 2218
                },
                {
                  "key": 0,
                  "doc_count": 38
                }
              ]
            }
          }
        },

I would like to draw the chart with x-axis to be time and y axis to be line chart of doc_count based on each key value of inner buckets with the legend to be the value of the key. Any help will be appreciated.
Note that the aggregated value might be missing for some buckets so need to handle when the key is missing in one time buckets (set the key count to 0). But you may assume only the key can be {0,1,2,3,4,5,6,7}

Hi Tingda!

I used your Elasticsearch response in an example in the Vega editor here.

What you're describing also sounds very similar to the visualization we walk through in the Kibana Vega tutorial. I think this may help as well, especially if you are wondering how to put your Elasticsearch query in the Vega config in Kibana.

Let me know if these help!

Thank you so much for the help! Really appreciated.

1 Like

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