Real-Time AWS Health Dashboard Updates via Slack Notifications

Home » Others » Real-Time AWS Health Dashboard Updates via Slack Notifications

Real-Time AWS Health Dashboard Updates via Slack Notifications

Last updated on September 2, 2024

In an organization or for users that use cloud services, staying updated with the status and health of cloud services is crucial. It’s not just about maintaining operational efficiency and minimizing downtime; it’s also about peace of mind and ensuring a seamless experience for both the team and customers. The AWS Health Dashboard provides detailed information about the health of AWS services and resources. To ensure timely awareness of any issues or updates, integrating the AWS Health Dashboard with communication tools like Slack can be highly effective. This integration allows for real-time notifications, ensuring that relevant teams are immediately informed of any critical updates. Imagine the advantage of knowing about an issue the moment it happens, empowering your team to take swift action and resolve problems before they escalate.

What is AWS Health Dashboard?

The AWS Health Dashboard is a feature-rich tool from Amazon Web Services (AWS) offering individualized insights into the condition of your AWS resources and services. You can use this to monitor the status and health of your AWS services and resources. It offers a customized view tailored to your specific AWS environment, ensuring that you receive relevant and timely information about any issues or changes that may affect your operations. 

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step Guide

AWS Services to be used are the following:

  1. Amazon EventBridge (CloudEvents)  – This service acts as the event bus, capturing events from AWS Health and routing them to targets like AWS Lambda.
  2. AWS Lambda – A serverless compute service that runs code in response to events, such as those captured by EventBridge.

Implementing AWS Health Dashboard Alert in Slack 

Monitoring AWS Health Dashboard using Slack enables your team to stay updated on critical events and service disruptions in real time, enhancing your incident response and operational efficiency. By integrating AWS Health Notifications with Slack, you can ensure that relevant alerts are instantly delivered to your team’s communication channels, facilitating prompt action and coordination. Here’s a step-by-step guide on how to set up this integration:

Tutorials dojo strip

Setting up Amazon EventBridge Rule

Step 1: Go to AWS Health Dashboard and configure Amazon EventBridge Rule

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step GuideStep 2: Click ‘Configure‘ to open a new tab. Enter your rule name, then click ‘Next‘.

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step GuideStep 3: Under ‘Build event pattern‘, select ‘AWS events or EventBridge partner events’ under Event Source.

Step 4: Using the details shown in the image, set the rule to listen to the ‘aws.health‘ source, then click ‘Next‘.

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step GuideStep 5: We can then configure the EventBridge rule to publish events to a Lambda function. After selecting the targets and reviewing the rule, you can now click ‘Create Rule‘.

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step Guide

Setting Up the Lambda Function

Step 1: Navigate to Lambda Console and click “Create Function“.

Step 2: Enter your Function Name and Runtime i.e.

  • Function name: aws-health-slack-notifier
  • Runtime: Python 3.11

Step 3: For the Lambda Code, copy and paste the code.

import json
import logging
import urllib3
from urllib.request import Request, urlopen, URLError, HTTPError

logger = logging.getLogger()
logger.setLevel(logging.INFO)

http=urllib3.PoolManager()
slack_webhook_url="YOUR SLACK_HOOK"
slack_channel="YOUR CHANNEL"

def handler(event, context):
     notification_description=event['detail']['eventDescription'][0]['latestDescription']
     eventArn=event['detail']['eventArn']
     phd_dashboard_url= "https://phd.aws.amazon.com/phd/home?region=us-east-1#/event-log?eventID=" + eventArn
     message=[
         {
           "type": "section",
           "text": {
           "type": "mrkdwn",
           "text": f":helmet_with_white_cross: AWS Health notification\n\n*{notification_description}*"
          }
         },
         {
           "type": "section",
           "text": {
           "type": "mrkdwn",
           "text": f"{phd_dashboard_url} | Click here for details."
          }
         }
      ]
      slack_message = {
         "channel": slack_channel,
         "blocks": message
       }
       enc_message=json.dumps(slack_message).encode("utf-8")
       logger.info(str(slack_message))
       req = Request(
               hook,
               data=json.dumps(slack_message).encode("utf-8"),
               headers={"content-type": "application/json"}
           )
       try:
            response = urlopen(req)
            response.read()
            logger.info("Message posted to: %s", slack_message['channel'])
       except HTTPError as e:
            logger.error("Request failed : %d %s", e.code, e.reason)
       except URLError as e:
            logger.error("Server connection failed: %s", e.reason)

Step 4: Under Configuration, click Trigger, then Click “Add Trigger”. Select Amazon EventBridge(CloudWatch Events) as the trigger. You can then choose the rule that we created earlier and then Choose “Add“. 

Integrating AWS Health Dashboard with Slack for Real-Time Notifications: A Step-by-Step Guide

That’s it! We have successfully set up the Lambda function and EventBridge rule.  

Testing for Slack Notifications

Now, let’s test the Slack notification to track the AWS Health Dashboard.

Step 1: On Lambda Console, navigate to the Lambda function that we created earlier.

Step 2: Under the Test section, copy and paste the dummy event data in the text field.

{
   "version": "0",
   "id": "fd9d4512-1eb0-50f6-0491-d016ae56aef0",
   "detail-type": "AWS Health Event",
   "source": "aws.health",
   "account": "123456789012",
   "time": "2023-02-15T10:07:10Z",
   "region": "us-east-1",
   "resources": [],
   "detail": {
     "eventArn": "arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE",
     "service": "EC2",
     "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE",
     "eventTypeCategory": "issue",
     "eventScopeCode": "PUBLIC",
     "communicationId": "01b0993207d81a09dcd552ebd1e633e36cf1f09a-1",
     "statusCode": "open",
     "eventRegion": "us-east-1",
     "eventDescription": [
      {
        "latestDescription": "We are investigating increased API Error rates and Latencies for Amazon Elastic Compute Cloud in the US-EAST-1 Region.",
        "language": "en_US"
      }
     ],
      "page": "1",
      "totalPages": "1",
      "affectedAccount": "123456789012"
    }
   }

Step 3: Click the Test button.

Step 4: Check your Slack channel to confirm whether a notification has been sent.

Conclusions

Integrating the AWS Health Dashboard with Slack for real-time notifications provides a robust solution for monitoring AWS service health and receiving immediate alerts. This integration ensures timely and automated communication of critical health events by leveraging AWS EventBridge, AWS Lambda, and AWS CloudFormation. This setup enhances operational awareness and responsiveness, allowing teams to address issues swiftly and maintain the reliability and performance of their AWS environments. This integration becomes straightforward with the step-by-step guide provided, enabling efficient and effective real-time monitoring and alerting.

Overall, this integration not only improves the ability to react promptly to AWS Health events but also promotes a proactive approach to infrastructure management. By receiving real-time notifications directly in Slack, teams can stay informed and collaborate more effectively, minimizing downtime and optimizing resource management. This streamlined communication channel ensures that the right people are connected to potential issues as soon as they arise, significantly improving your AWS environment’s overall resilience and performance.

Tutorials Dojo portal

Founder Spotlight: Jon Bonso

jon bonso

Enroll Now – Our Google Cloud Certification Exam Reviewers

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Irene Bonso

Irene Bonso is currently thriving as a Junior Software Engineer at Tutorials Dojo and also an active member of the AWS Community Builder Program. She is focused to gain knowledge and make it accessible to a broader audience through her contributions and insights.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?