Cloudwatch Metric query to include both Memory and CPU utilization

0

Hi, We have a CloudWatch custom alarm based on the average memory usage of and autoscaling group containing 2 EC2 instances, with the query being

SELECT AVG(mem_used_percent) FROM SCHEMA(CWAgent, AutoScalingGroupName,ImageId,InstanceId,InstanceType) WHERE AutoScalingGroupName = 'asg_name'

In this query, if usage surpasses 70%, autoscaling is automatically triggered and an additional EC2 instance is added.

Is it possible for me to add the average CPU_utilization >= 70% to this query as well? I tried using the 'UNION' operator, but unfortunately it does not work. Please help.

Note: Autoscaling group name has been changed to 'asg_name' to protect confidentiality.

2 Antworten
0

Hi, you cannot mix two different metrics, UNION or apply metric maths on top of a Metrics Insights query. An alternative would be to create 2 distinct alarms, one on the CPU, one on the Mem, and join them using a composite alarm. The drawback is that there is no direct integration between the composite and autoscaling actions, so it may not be as easy to control scale up/down from there as from a metric alarm.

Otherwise as suggested by rePost-User-0046670 you could try to come up with a math expression to define your condition.

profile pictureAWS
Jsc
beantwortet vor 7 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen