Send CloudWatch alarm to Slack via AWS Chatbot

15 / Mar / 2024 by Ahmad Ali 0 comments

Introduction

One of the critical elements for production uptime is Monitoring and Alerts. Irrespective of the infrastructure types such as EC2 Servers, Serverless, containers, or microservices. There will always be observability needs.

There are a lot of tools and software in this Observability market. However, this article focuses on cloud platform tools, such as AWS Cloudwatch

Objective

This article will help you to understand and configure AWS Cloudwatch to monitor applications efficiently. In this article, you will also see how  to send Cloudwatch alarms to Slack using AWS Chatbot integration

Prerequisites

  • AWS Account
  • Slack Channel

Steps by Step Procedure

1. CloudWatch Alarm setup for ECS CPU Metric

In your AWS console, visit CloudWatch, then to Alarms and click on All-alarms under the Alarms menu.

After clicking on the All-alarms, you will see a button on the top right named Create Alarm to create a new alarm. Click on Create Alarm and click on the Select Metric button. Check the below image for reference.

After you click the Select Metric button, you will be asked to fill in the metric of your choice & metric conditions. Check the screenshot below for reference. Specify the Conditions as per the requirement, After specifying the conditions click on next to configure the SNS topic.

In the Configure Actions screen, Choose the SNS Topic to receive a notification when an alarm triggers. Either you can choose your existing SNS topic or Create a new topic.

In my case, it is Cloudwatch-SNS-Topic.

Now the Cloud Watch Alarm is ready, Let’s proceed to the Slack Integration with AWS Chatbot.

2. Creating AWS Chatbot and integration of SNS topic and Slack Channel

In the AWS console, Search  and select AWS Chatbot and click on Configure New Client

Once you click, you will see two options: Choose Slack and Configure

As you click the configure button, you will be redirected to a Slack authorization screen. If you are not already logged into Slack using the same browser, you will be asked to log in.

Once you have authorized it, you will be redirected to AWS, and you can see new Configured Clients with your Slack Organization name.

Click on the Configure new channel

You Need to fill in the following items : 

  • Configuration name: Name for the Slack channel configuration
  • Channel Type: Set channel type to be Public or Private
  • Name of the Channel: Browse and select the channel where the alert should be sent.
  • Channel role: Leave this as the default. The AWS will create an IAM role.
  • Guardrail policy: Specify the minimal IAM Policy so that you can prevent Slack from connecting back to AWS. And even if it will limit the permission.
  • NotificationsSNS Topic: Choose the SNS topic where the chatbot would send alerts.

After filling out the above details, click on the Configure button. You will now see the screen like this.

3. Add the AWS ChatBot App to the Slack Channel

Open the Slack channel, Goto Channel details tab, and Add the AWS Chatbot app using the Add Apps option

In the Search bar, input AWS Chatbot and choose the AWS Chatbot App, and click on Add

A message will pop up saying, “AWS app was added to the channel on the channel itself.

Conclusion

Now, whenever the CloudWatch alarm transitions to an ALARM state, you will be notified here on the Slack channel.

FOUND THIS USEFUL? SHARE IT

Tag -

devops

Leave a Reply

Your email address will not be published. Required fields are marked *