Can AWS CloudWatch alarms be paused/disabled during specific hours?

一世执手 提交于 2019-11-30 13:14:26

问题


I want to automatically toggle alarms on/off during specific periods of time so that they do not fire during maintenance windows. I'm doubting that an easy or direct method exists since I could not find such a thing in the documentation. Does anyone know of a different approach to achieve this while still using CloudWatch alarms, or did I miss an obvious solution?


回答1:


It's not automatic but it can be done:

http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_EnableAlarmActions.html

What you want to do is: right before the maintenance window starts you Disable the alarm actions. As the windows ends you Enable the alarm actions.




回答2:


I got here while looking for something that would help me to disable alerts for my machine which is performing backups every Saturday between 11:00 and 11:30. The only solution I found is to create cronjob to disable/enable particular alert and run them on particular times:

59 10 * * 6 ec2-user aws cloudwatch disable-alarm-actions --alarm-names "Alarm-1" "Alarm-2"
31 11 * * 6 ec2-user aws cloudwatch disable-alarm-actions --alarm-names "Alarm-1" "Alarm-2"

Your node needs to have access to CloudWatch, obviously. I gave it CloudWatchFullAccess.




回答3:


Yeah, just as above you can do it using CLI. Also, you can stop sending data from scripts INCASE of custom metrics so that will automatically stop the alarm.

Another way is you can write a script where you can have defined alarm using put-alarm (CloudWatch CLI ). There could be a function that creates alarms and one that deletes them. Call them when needed.




回答4:


Agreed. Felt this pain on "presence of data" alarms over "off hours". I would be looking to leverage AWS Lambda's scheduled CloudWatch triggers which is our new go-to scheduler for actions invoked at a rate less than 1/minute.

https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.disable_alarm_actions



来源:https://stackoverflow.com/questions/24737359/can-aws-cloudwatch-alarms-be-paused-disabled-during-specific-hours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!