Automating alarm notification using email and a Slack channel
So far, we have discussed CloudWatch for monitoring and SNS for alerting. But nowadays, a newly emerging field is ChatOps, whereby your DevOps/System team can receive a notification on a collaboration platform such as Slack. Unfortunately, SNS doesn't support out-of-the-box Slack integration, so we need to use AWS Lambda for that.
The way the whole integration works is that CloudWatch will trigger an alarm that sends messages to SNS topics when certain events occur—in this case, when CPU utilization goes beyond 40%. A Lambda function will get invoked in response to SNS, and it will then call the Slack API to post the message to the Slack channel.
Configuring Slack
To configure Webhooks in Slack for CloudWatch Alarms, we perform the following steps:
- As a first step, we need to create a Slack app. To do that, go to this URL at https://api.slack.com/apps/new and fill in the following details:
- App...