CloudWatch sorting instances by Tags

Hi,

I’m sorry if this question has already been solved somewhere, but I couldn’t find any suitable solution for this specific issue.

I’m setting-up a custom CloudWatch Dashboard and I would like to repeat a row, based on AWS tags (to isolate my environment’s VMs tagged like “dev”, “prod” …).

So I have two variables :

 $env_set	ec2_instance_attribute(eu-west-3, Tags.env, {})
 $environment	ec2_instance_attribute(eu-west-3, InstanceId, { "tag:env" : [ "$env_set" ] } )

I set up the row containing my graph query to repeat for every $env_set. It does work only if a unique environment is selected. If I have multiple env, I just have “no data”.
The problem is (or seems to be), the $environment variable doesn’t repeat for every $env_set value.

Here is my query :

To summarize, I would like to dynamically create new rows that contains all my EC2 (and RDS etc…) under the same AWS tage.

Thanks alot for the help.