2017-05-14 3 views
0

내 조직에서 다음 5 시간 동안 유지 관리 기간을 계획하고 있습니다. 그동안 Cloud Watch에서 경보를 보내고 알림을 보내지 않기를 바랍니다.모든 클라우드 감시 알람을 한 번에 사용 중지하려고합니다.

이전에는 4 개의 알람을 비활성화해야 할 때 AWS Lambda에 다음 코드를 작성했습니다. 이것은 잘 동작했다.

import boto3 
import collections 

client = boto3.client('cloudwatch') 

def lambda_handler(event, context): 
    response = client.disable_alarm_actions(
    AlarmNames=[ 
     'CRITICAL - StatusCheckFailed for Instance 456', 
     'CRITICAL - StatusCheckFailed for Instance 345', 
     'CRITICAL - StatusCheckFailed for Instance 234', 
     'CRITICAL - StatusCheckFailed for Instance 123' 
    ] 
) 

하지만 지금은 361 개의 모든 알람을 사용 중지하도록 요청 받았습니다. 따라서 모든 이름을 포함하면 많은 시간이 걸릴 것입니다.

지금 무엇을해야하는지 알려주십시오.

답변

1

그 목록을 얻기 위해 사용 describe_alarms(), 다음을 통해 반복하고 해제 :

import boto3 
client = boto3.client('cloudwatch') 

response = client.describe_alarms() 

names = [[alarm['AlarmName'] for alarm in response['MetricAlarms']]] 
disable_response = client.disable_alarm_actions(names) 

는 만 해제 특정 알람을 알람 이름 주위에 약간의 논리를 할 수 있습니다.