logo
Integrate Slack channel & CloudWatch alarm using AWS Chatbot

Integrate Slack channel & CloudWatch alarm using AWS Chatbot

This post describes steps required to integrate a slack channel with cloud watch alarms using AWS chatbot service.

Published Feb 12, 2024
Integrate Slack channel and CloudWatch alarms using AWS Chatbot
Do you know that AWS ChatBot is one of the 227 services (as of 1/2/24) provided by AWS?
AWS ChatBot provides a quick and easy way to integrate your cloud watch alarms and other triggers with Slack channel.
Slack is a popular team tool for communication and collaboration. I will integrate Slack channel so that AWS Services event based on rules defined get posted to this slack channel directly. It will allow team members to get instant notification of these events and then take appropriate actions.
Integrating AWS Chatbot with Slack channels is like bringing your AWS alerts and updates directly to your team chat. This means you get instant notifications on Slack, making it easy for everyone to stay in the loop. Whether it's alerts or specific triggers, you can customize what you receive, making communication streamlined and efficient. With AWS Chatbot in Slack, your team can discuss, troubleshoot, and take action right where they're already collaborating. It's a simple way to enhance visibility, speed up decision-making, and create a more connected and responsive cloud management experience.
In our business use case, we aim to integrate a Slack channel based on the number of invocations for a Lambda function. This Lambda function can be triggered through various methods, such as Postman, APIs, or applications. By implementing this integration, we ensure that our team stays informed on Slack about the frequency of Lambda function invocations. This real-time notification system enhances visibility into our serverless operations, allowing for prompt awareness and collaboration among team members, whether the function is invoked manually through Postman or automatically via APIs or applications.
Here is the architecture diagram for our use case.
AWS Chatbot & Slack Integration
AWS Chatbot & Slack Integration
Let's see the steps to create this integration!
Create s slack channel
I have created a slack channel - refunderrors.
CloudWatch alarm notification will be posted in this channel.
Slack Channel
Slack Channel
Create a SNS topic
I have created a SNS topic – refund_errors_gb
SNS Topic
SNS Topic
Configure AWS Slack Chatbot using AWS Console
Use AWS console to configure AWS Slack Chatbot.
Chat Client
Chat Client
Allow AWS service permission to integrate with Slack channel.
Chat Bot Permissions
Chat Bot Permissions
Select Notification
Select notification in the last step of this configuration
I will select the region and SNS topic. Remember, I have already created SNS topic, I am just selecting the topic from the drop down in this step.
Notification
Notification
Create a CloudWatch alarm
I am creating a CloudWatch alarm based on # of invocation for lambda function, however, you can create the alarm based on your specific use case.
Cloud Watch Alarm
Cloud Watch Alarm
Invoke Lambda function few times
I am invoking the lambda function by calling the restful API using postman, however you can invoke it via your app integration or API integration. Once invoke few times, and metrics per the defined alarm rule meet the criteria, you will see that cloud watch alarm is In Alarm status.
Invoke Lambda
Invoke Lambda
Review Slack channel
Once alarm is in alarm status, a notification will be published to slack channel integrated via AWS chatbot. Review the notification below:
Review Notificaiton
Review Notificaiton
Review Notificaiton2
Review Notificaiton2
That's it! Integrating AWS with your Slack channel is a straightforward process. Once set up, all team members or operations teams subscribed to the Slack channel will receive notifications when the specified alarm is triggered. This example uses a basic alarm, but you have the flexibility to customize and trigger alarms based on any metrics that align with your unique business use case. This simplicity and adaptability make AWS and Slack integration a powerful combination for streamlined communication and effective management of your cloud operations.
Thanks for reading!
π’’π’Ύπ“‡π’Ύπ“ˆπ’½ ℬ𝒽𝒢𝓉𝒾𝒢
𝘈𝘞𝘚 𝘊𝘦𝘳𝘡π˜ͺ𝘧π˜ͺ𝘦π˜₯ 𝘚𝘰𝘭𝘢𝘡π˜ͺ𝘰𝘯 𝘈𝘳𝘀𝘩π˜ͺ𝘡𝘦𝘀𝘡 & π˜‹π˜¦π˜·π˜¦π˜­π˜°π˜±π˜¦π˜³ 𝘈𝘴𝘴𝘰𝘀π˜ͺ𝘒𝘡𝘦
𝘊𝘭𝘰𝘢π˜₯ π˜›π˜¦π˜€π˜©π˜―π˜°π˜­π˜°π˜¨π˜Ί 𝘌𝘯𝘡𝘩𝘢𝘴π˜ͺ𝘒𝘴𝘡
Β