How to do a stacked bar chart with different elasticsearch queries

I have 2 different queries that return the same table fields: allow and block, but with the values of each query.

The returned series have the same name. I don’t know how to name them after the query name (I don’t know if this has any importance for the final goal)

I want to build a stacked bar chart like:

image

each bar is a query, and allow and block values are stacked for each bar.

I have been trying to do some transformations so my data ends as needed for stacking

query/utmaction allow block
countapp 100 10
countweb 200 20

but had no success yet.

the furthest I’ve come is:

but can not add the query name to the table

I was able to add a row id, but the problem is that the order is not always the same

if I could find a way to rename the frame, or to somehow reference it on a row, that would do the magic

turns out that not retriving the series always on the same order was not a Grafana issue, but from the datasource itself.

So I was able to pull it off.

1 Like