Graph template for stacked data

I am tryting to make the following graph.
There are 3 machines and they give logs with erroe code.

I am using elasticsearch in grafana.

I used Graph template and
Query: machine.keyword: $MACHINE
Group by: error code


It is ok to make the total count graph but it is hard to know how I can show each machine’s count like the picture 1.
Which template can I try?

  1. what version of es
  2. Could you please provide a sample elasticsearch document?


The version is 7.12.0.
There are code, eqpid, time and log type.

“fields”: {
“code.keyword”: [
“eqpid.keyword”: [
“2022-08-29 08:37:54”
“logcategory.keyword”: [