![Integrate Slack channel & CloudWatch alarm using AWS Chatbot](https://assets.community.aws/a/2cFMl8LVhDt0nBAMN5ywrSDwKZd/Comm.webp)
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
Last Modified Apr 14, 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](https://assets.community.aws/a/2cFEc39khq1h30M1uegBR5O0Oz2/AWS-.webp)
Create s slack channel
I have created a slack channel - refunderrors.
CloudWatch alarm notification will be posted in this channel.
![Slack Channel Slack Channel](https://assets.community.aws/a/2cFF6RrinzEdIkKogkFDwv9nde3/img1.webp)
I have created a SNS topic β refund_errors_gb
![SNS Topic SNS Topic](https://assets.community.aws/a/2cFFD7uTFDRsac1xgsWWF2RbRk6/img2.webp)
Use AWS console to configure AWS Slack Chatbot.
![Chat Client Chat Client](https://assets.community.aws/a/2cFFHCGGmkQRzo6DXBWJNOtjYkm/img3.webp)
![Chat Bot Permissions Chat Bot Permissions](https://assets.community.aws/a/2cFFMCVvtL3ZUcTrnxrGFkvfnnL/img4.webp)
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](https://assets.community.aws/a/2cFFRL6UsvmDhuiKWCHHtzvsiDf/img5.webp)
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](https://assets.community.aws/a/2cFFZGn3u8NpUZXOali26lybK7r/img6.webp)
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](https://assets.community.aws/a/2cFFjQyEkn1nzMVoB7lt7xMWBDj/img1.webp)
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](https://assets.community.aws/a/2cFFogrKsiqZvHDNubiSsZDdZZU/img7.webp)
![Review Notificaiton2 Review Notificaiton2](https://assets.community.aws/a/2cFFrOFO1iRiotZYNiYfOMMLWoD/img8.webp)
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!
Click here to get to YouTube video for this solution.
π’πΎππΎππ½ β¬π½πΆππΎπΆ
πππ ππ¦π³π΅πͺπ§πͺπ¦π₯ ππ°ππΆπ΅πͺπ°π― ππ³π€π©πͺπ΅π¦π€π΅ & ππ¦π·π¦ππ°π±π¦π³ ππ΄π΄π°π€πͺπ’π΅π¦
πππ°πΆπ₯ ππ¦π€π©π―π°ππ°π¨πΊ ππ―π΅π©πΆπ΄πͺπ’π΄π΅
Β
Β