A little bit complicated alert - looking for a hint

Hey dear community :wave:,
We use brand new Grafana 9 and I’m struggling a little bit with new generation alerting feature :frowning_face:.
I would like to create alert “when any of AutoScalingGroupName reached the GroupMaxSize count.” base of CloudWatch metrics.

I use this two queries:
To get maximum allowed number of nodes per group:
SELECT AVG(GroupMaxSize) FROM "AWS/AutoScaling" GROUP BY AutoScalingGroupName

To get current number of nodes per group:
SELECT AVG(GroupInServiceInstances) FROM "AWS/AutoScaling" GROUP BY AutoScalingGroupName

Each query returns set of common group names with values.

How should query/expression look like to achieve desired result? :thinking:
Any hints helps. Thank you :pray:.

In both cases you are using AVG function

For maximum I would think you would use MAX()

And for number of you would use COUNT ?

Thank you @yosiasz for your suggestions :+1:.
Sadly this doesn’t solve my initial problem which I have.
I need figure out how to create proper expression to alarm when:

Value of group name XY from GroupInServiceInstances is equal to value from group name XY from GroupMaxSize without having statically defined group names, like XY.

I have metrics like this:
GroupInServiceInstances: AAA - 3; BBB - 3; CCC - 5
GroupMaxSize: AAA - 4; BBB - 3; CCC - 6