Search code examples
elasticsearchkibana

Kibana visualize, count the length of the array


I got the documents like this enter image description here

TradeInfoList contains 3 records.

The question is how to count this in the visualize module.

Like I got two documents, one of them got 2 Trade Info, another one got 3 Trade Info, I want to sum them and show 5 in the visualize. How can I do that, I have try scripted fields, seem not working.


Solution

  • First of all you need to create a metric panel, then choose sum as aggregation. After that select TradeInfoList as the field, on the end you write down script in advance -> JSON input

    {
      "script": "return doc['TradeInfoList'].value"
    }