AWS Management & Governance Blog

Monitor Amazon EventBridge events in your Slack channels with AWS Chatbot

DevOps teams use chat collaboration platforms such as Slack and Amazon Chime to monitor systems and respond to events. When AWS Chatbot is integrated with Slack and Chime, users can monitor and interact with AWS resources from the chat channels, which reduces context switching between applications. DevOps users now can receive notifications from more than 200 service event types in chat channels through Amazon EventBridge.

In this blog post, I will share the steps for setting up an Amazon EventBridge rule and configuring AWS Chatbot to receive notifications in a Slack channel.

How it works

Amazon EventBridge enables applications to route events from AWS services and other data sources to various destinations such as Amazon Simple Notification Service (Amazon SNS) topics and AWS Lambda functions. To receive service event notifications in chat channels, you configure an SNS topic as a target in the Amazon EventBridge rule and then associate the topic with a chat channel in the AWS Chatbot console. When EventBridge receives an event with an event pattern that matches the event pattern defined in the rule, the event rule fires and the event notification is sent to the configured chat channel.

In this tutorial, you will perform the following steps:

  1. Create an SNS topic. (optional)
  2. Configure an EventBridge rule for Amazon Elastic Container Service (Amazon ECS) state change events.
  3. Create an AWS Chatbot configuration.
  4. Test the EventBridge rule.

Prerequisites

You will need the following:

  • An AWS account.
  • A Slack channel with the AWS Chatbot app installed.
  • An Amazon ECS cluster.

For this post, you will use an Amazon ECS cluster to demonstrate ECS state change event notification delivery to a Slack channel. You want to receive a notification to the Slack channel every time the ECS cluster state changes so that you can diagnose and fix any issues.

Step 1: Create an Amazon SNS topic

First, create an SNS topic to connect EventBridge with AWS Chatbot. If you already have an SNS topic, you can skip this step.

In the SNS console, choose Topics, and then choose Create topic. Give your topic a descriptive name and keep the other parameters their default.

Step 2: Configure an Amazon EventBridge rule for an ECS state change event

  1. In the Amazon EventBridge console, choose Rules, and then choose Create Rule.
  2. Enter a descriptive name for your rule.
  3. For Define pattern, choose Event pattern.
  4. Choose pre-defined pattern by service to define a pattern to match events.
  5. For Service provider, choose AWS.
  6. For Service name, choose Elastic Container Service (ECS).

Note: Currently, only events from AWS services supported in EventBridge are delivered to the chat channels with AWS Chatbot.

  1. For Event Type, choose State Change as the type of event to use for this rule. You can optionally choose the detail type and cluster.

The Define pattern page displays fields that are completed as described in the procedure. 

Figure 1: Define pattern

  1. In Select targets, for Target, choose SNS topic as the target to invoke when the ECS state change event triggers this rule.
  2. For Topic, choose the SNS topic you created in Step 1 of this post.

Select targets displays a Target section. SNS topic is selected from the dropdown as the rule target when the event is triggered. Under Topic, TopicForAWSChatbotNotifications is displayed.

Figure 2: Select targets

  1. Complete the rule-creation process with the default settings.

Step 3: Create an AWS Chatbot configuration

Now you are ready to start configuring AWS Chatbot with the chat client.

  1. In the AWS Chatbot console, choose Configure new client.
  2. In Configure new client, choose Slack.
    The setup wizard redirects you to the Slack OAuth 2.0
  3. In the top-right corner, choose the Slack workspace to configure, and then choose Agree.Your Slack workspace installs the AWSChatbot Demo Slack app. The AWS account that you used to sign in can now send notifications.

AWS Chatbot is requesting permission to access the AWS Chatbot Demo Slack workspace.

Figure 3: AWS Chatbot requests access to Slack workspace

  1. From here, Slack redirects you to the Configure Slack Channel Choose the channel in which to receive notifications. You can choose a public channel from the dropdown list or paste the URL or ID of a private channel.To find the URL of your private Slack channel, in Slack’s left sidebar, open the context (right-click) menu on the channel name and choose Copy link. AWS Chatbot can work in a channel only if you add AWS Chatbot app (@aws) to the Slack channel. If the AWS Chatbot app has not been added, from the channel’s Details page, choose Add apps.
  2. After you choose the Slack channel, under IAM Permissions, use an existing IAM role or create one using a policy template. To receive EventBridge notifications, the role must have notifications permissions.
  3. Finally, under SNS topics, choose the SNS topic that you created in Step 1. You can select multiple SNS topics from more than one region, granting them all the ability to notify the same Slack channel.
  4. Choose Configure to complete the configuration.

Step 4: Test the alarm

You can test this setup by manually stopping your ECS tasks or services. This should trigger an alarm and send a notification in your Slack channel.

The notification text says, “An ECS task running on cluster ‘Default’ transitioned to PENDING status.”

Figure 4: Notification about ECS task state change

Conclusion

DevOps users can now monitor an expanded range of AWS services in AWS Chatbot-configured chat channels. This integration with Slack and Chime reduces context switching and provides an opportunity to monitor applications and CI/CD workflows from chat channels. For more information on AWS Chatbot support for AWS Services through Amazon EventBridge, see Using AWS Chatbot with other AWS services in AWS Chatbot Administrator guide.

Got any ideas to improve AWS Chatbot? You can send your comments to the AWS Chatbot team by typing @aws feedback <your comments> in your Slack channel.

About the authors

Abhijit Barde

Abhijit Barde

Abhijit Barde is the Principal Product Manager for AWS Chatbot, where he focuses on making it easy for all AWS users to discover, monitor, and interact with AWS resources using conversational interfaces.

Arnab Deka

Arnab Deka

Arnab Deka is a Senior Software Development Engineer with AWS Chatbot. Arnab is a polygot developer with experience across multiple industries. He loves to improve customer experience by building systems and APIs for high scalability and usability.

Prabhakar Ganesamurthy

Prabhakar Ganesamurthy

Prabhakar Ganesamurthy is a Senior Software Engineer at AWS. He is passionate about improving user experiences for AWS Customers and building unified notification experience across all AWS Services.