Skip to content

Commit

Permalink
state the time of the alert
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Aug 20, 2021
1 parent 5ecec8e commit 6e624da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lambda/handler.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ def lambda_handler(event, context):
myMessage= json.loads(event['Records'][0]['Sns']['Message'])
AlarmName= myMessage["AlarmName"]
Region = myMessage["AlarmArn"].split(":")[3]
StateChangeTime=myMessage["StateChangeTime"]

Link="https://{1}.console.aws.amazon.com/cloudwatch/home?region={1}#alarmsV2:alarm/{0}?~(alarmStateFilter~'ALARM)".format(AlarmName, Region)

# Construct the message
payload=f"""
Alarm raised by Cloudwatch:
{Link}
{myMessage}"""

At {StateChangeTime}"""

# Send
resp = client.publish(TargetArn=sns_arn, Message=payload, Subject=mySubject)

0 comments on commit 6e624da

Please sign in to comment.