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.

已提問 8 個月前檢視次數 668 次
2 個答案
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
已回答 7 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南