Stacked Bars with Elasticsearch/Lucene in Grafana 12.3.1

  • What Grafana version and what operating system are you using?

12.3.1, Ubuntu 22.

  • What are you trying to achieve?

Using an Elasticsearch data source and a Lucene query, I have a horizontal bar chart showing the top 5 doc counts of the string field “message.software.name.raw”. For each of those 5 bars, I want to break them down by the field “message.software.component.raw”. So then each bar will show the total records, but be composed of different-colored parts that describe how many of each of the top 5 components contribute to the length of the bar. 5 bars, 1 for each of the top five software, broken down into the top 5 parts describing software components.

  • How are you trying to achieve it?

I have a Lucene query which gives me the numbers that I expect. Then:

Metric: Count

Group By: Terms - “message.software.name.raw” - Top 5, Order By Doc Count

Then By: Terms - “message.software.component.raw” - Top 5, Order By Doc Count

  • What happened?

No matter how I configure the chart, I cannot get the behaviour I want. I end up with 10 bars on the graph, 5 that describe the top 5 software counts, then 5 that describe component. I can’t get them to stack. I’ve tried every variation of setting the “X Axis” setting and “Color by field” setting. Flipping “Stacking” between “Off” and “Normal” has no effect.

  • What did you expect to happen?

I’m hoping for the stacking I described at the start.

  • Can you copy/paste the configuration(s) that you are having problems with?

N/A

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

N/A

  • Did you follow any online instructions? If so, what is the URL?

I asked Grot AI but it says that there is not enough documentation it is trained on to provide a working answer.