Visualize Dynamic Series in line chart

I've got some JSON documents flowing into my ES cluster. They look kind of like this:

    {
      "stats": {
        "Series 1": {
          "count": 134,
          "registered": 0
        },
        "Series 2": {
          "count": 3,
          "registered": 1
        },
        "Series 3": {
          "count": 4,
          "registered": 1
        },
        "Series N": {
          "count": 3,
          "registered": 3
        }
      },
      "timestamp": "2020-12-15T19:00:15.208029Z"
    }

As shown, there is a "stats" key that has N series of data entries in it. Each entry has two values. The entire document is timestamped. How would I visualize, say, the "count" field for each series in this document in a line graph where the graphs legend shows the name of each series and plots a line for each series.

Furthermore, the number of series in the "stats" key is dynamic and may change over time. In the previous example, there are 4. Later on, there may be 40.

Is this possible via aggregation bucketing or something to that effect.?

It would be possible if your documents were structured differently, but not with that structure. Kibana mostly requires you to know your keys ahead of time. You are allowed to use array structures (which have many caveats, see docs). Because of the caveats I think you would benefit from storing a separate document for each series, so that each series can have a name or other ID field. Here's what I would recommend:

{
  "name": "Series 1",
  "count": 134,
  "registered": 0,
  "timestamp": "2020-12-15T19:00:15.208029Z"
}

I was afraid of that. I don't have much control over the incoming document format at the moment. Thanks for the quick reply.

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