DEV Community

Cover image for Building a Serverless Website Uptime Monitor with AWS Lambda, EventBridge, and SNS
Emmanuel Ulu
Emmanuel Ulu

Posted on

Building a Serverless Website Uptime Monitor with AWS Lambda, EventBridge, and SNS

Introduction

In modern cloud environments, ensuring that applications and websites remain available is critical. Even a few minutes of downtime can affect users, revenue, and system reliability.

In this project, I built a simple serverless uptime monitoring system using AWS services. The system periodically checks whether a website is available and sends an alert if it becomes unreachable.

This project demonstrates how event-driven architectures can automate monitoring tasks without managing servers.

The Business Problem

Many small teams and startups rely on web applications but may not have a full monitoring stack.

Some common problems include:

  • Websites going down without immediate notice

  • Lack of automated monitoring

  • Delayed response to service failures

  • Expensive third-party monitoring tools

The goal of this project is to create a lightweight and cost-efficient monitoring system that automatically checks website availability and sends alerts when problems occur.

The Solution

Using a serverless architecture, we can automate uptime monitoring with minimal infrastructure.

AWS architecture diagram where EventBridge triggers a Lambda function to perform a website health check, logs results to CloudWatch, and sends alerts through SNS to Slack and email if the site is down.
Figure: Serverless architecture for automated website uptime monitoring using AWS EventBridge, Lambda, SNS, and CloudWatch. Alerts are delivered via Slack or email when the monitored service becomes unavailable.

The system works as follows:

  1. A scheduler triggers a function at regular intervals.

  2. The function checks the health of a target website

  3. If the website is down, an alert notification is sent.

  4. Logs and metrics are stored for monitoring and troubleshooting.

Architecture

The architecture uses the following AWS services:

  • Amazon EventBridge – schedules the monitoring job

  • AWS Lambda – runs the health check logic

  • Amazon Simple Notification Service – sends alert notifications

  • Amazon CloudWatch – collects logs and metrics

Workflow:

EventBridge (schedule)
        ↓
Lambda Function
        ↓
Website Health Check
        ↓
SNS Notification
        ↓
Email / Slack
Enter fullscreen mode Exit fullscreen mode

Step 1: Create an SNS Topic

First, create a notification channel for alerts.

  1. Open the AWS Console.

  2. Navigate to SNS.

  3. Create a new Topic.

  4. Select Standard topic.

  5. Add a name such as:

website-health-alerts
Enter fullscreen mode Exit fullscreen mode

Next, create a subscription:

  • Protocol: Email

  • Endpoint: your email address

Confirm the subscription from your email.

Step 2: Create the Lambda Function

Next, create the function responsible for checking website health.

  1. Navigate to Lambda

  2. Click Create Function

  3. Choose Author from scratch

Configuration:

Function name: website-health-check
Runtime: Python
Enter fullscreen mode Exit fullscreen mode

Step 3: Add Health Check Code

Example Python code for the Lambda function:

import requests
import boto3
import os

sns = boto3.client('sns')

TOPIC_ARN = os.environ['SNS_TOPIC']

def lambda_handler(event, context):

    url = "https://google.com"

    try:
        response = requests.get(url, timeout=5)

        if response.status_code != 200:
            sns.publish(
                TopicArn=TOPIC_ARN,
                Message=f"ALERT: {url} is DOWN",
                Subject="Website Health Alert"
            )

    except Exception as e:
        sns.publish(
            TopicArn=TOPIC_ARN,
            Message=f"ERROR accessing {url}: {str(e)}",
            Subject="Website Health Alert"
        )
Enter fullscreen mode Exit fullscreen mode

This code checks whether the website responds successfully.

If the site is unavailable, it sends a notification to SNS.

Step 4: Configure EventBridge Scheduler

Now we automate the monitoring.

  1. Navigate to EventBridge

  2. Create a Rule

  3. Choose Schedule

Example schedule:

rate(5 minutes)
Enter fullscreen mode Exit fullscreen mode

Set the target to the Lambda function.

Now AWS will automatically run the health check every five minutes.

Step 5: Monitoring with CloudWatch

All Lambda executions generate logs automatically in CloudWatch.

CloudWatch allows you to monitor:

  1. execution logs

  2. errors

  3. function duration

  4. invocation metrics

This helps with troubleshooting if the health check fails.

Testing the System

To test the monitoring system:

  1. Change the URL in the Lambda function to an invalid website.

  2. Wait for the scheduled execution.

  3. An email alert should be triggered.

Example alert message:

ALERT: https://example.com is DOWN
Enter fullscreen mode Exit fullscreen mode

Benefits of This Approach

This serverless solution provides several advantages:

  • No server management

  • Automatic scaling

  • Low operational cost

  • Event-driven automation

  • Simple monitoring setup

Because the system only runs when triggered, it is cost efficient compared to always-on monitoring services.

Possible Improvements

This project can be extended in several ways:

  • Store monitoring results in DynamoDB

  • Track response latency

  • Monitor multiple websites

  • Send Slack alerts

  • Build a CloudWatch dashboard

  • Add retry logic

Conclusion

This project demonstrates how serverless services can be used to build lightweight automation tools.

By combining EventBridge, Lambda, SNS, and CloudWatch, we created a simple monitoring system that automatically checks website availability and sends alerts when issues occur.

Serverless architectures like this are powerful for operational automation because they eliminate the need to manage infrastructure while still providing reliable and scalable solutions.

I recently joined the AWS Community Builders program in the Serverless category, and I’ll be sharing more hands-on projects as I explore event-driven architectures and serverless systems.

Top comments (0)