英文:
AWS CLI command to get list of ec2 instances filtered according to no. of alarms attached
问题
我必须删除附加到EC2实例的一些冗余警报。为此,我需要筛选那些附加了超过2个警报的EC2实例。但我没有找到AWS提供的任何筛选实例的筛选器,以基于附加的警报来筛选它们。
此外,描述警报命令在这里没有帮助,因为每个实例都附加了唯一的警报。
英文:
I have to delete the some redundant alarms attached to the EC2 instances. For that I need to filter those EC2 instances which have more than 2 alarms attached. But I am not finding any filter provided by AWS through which I can filter the instances based on the attached alarms.
Also, describing alarms command would not help here as to every instance a unique alarm is attached.
答案1
得分: 1
这将提供一个包含在您帐户中定义的CW警报维度中的所有EC2实例的列表(相当于附加的不准确术语):
aws cloudwatch describe-alarms --query 'MetricAlarms[*].Dimensions[?(Name==`InstanceId`)].Value' --output text | sort
sort
将为您提供排序后的列表,因此任何重复的InstanceId表示它有多于1个警报。
英文:
This will give a list with all ec2 instances defined in CW alarms dimensions in your account (equivalent to inaccurate term of attached):
aws cloudwatch describe-alarms --query 'MetricAlarms[*].Dimensions[?(Name==`InstanceId`)].Value' --output text | sort
The sort
will give you the list ordered, so any repeated instanceId, that means it has more than 1 alarm.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论