In a world of microservices and containerized applications, just deploying isn’t enough. We need to monitor our applications continuously to ensure they are always up and responsive.
In this blog, I’ll walk you through how I set up a Heartbeat Canary using Amazon CloudWatch Synthetics to monitor an ECS-hosted website behind an ALB and CloudFront.
📦 Project Overview
I built a simple ECS-based website with the following architecture:
CloudFront (CF) ↓ Application Load Balancer (ALB) ↓ ECS Service ← ECR-hosted container image ↓ CloudWatch Canary (Heartbeat Monitoring)
🚦 What Are AWS CloudWatch Canaries?
AWS CloudWatch Canaries are synthetic monitoring scripts that simulate the same actions a user would take on your application. They’re like robotic testers—executing predefined tasks at regular intervals and alerting you if things go wrong.
They use Node.js-based scripts to interact with websites, APIs, or endpoints and report back performance, uptime, and correctness of services.
🧰 Types of Canaries Available
When creating a canary, AWS provides multiple blueprints tailored for different monitoring needs:
CloudWatch Canary Blueprint Types & Use Cases
Blueprint Type | Use Case |
---|---|
Heartbeat Monitoring | Check if an endpoint is alive (ping a URL) |
API Canary | Monitor API health and responses via HTTP steps |
Broken Link Checker | Crawl a web page and detect broken links |
Visual Monitoring | Detect changes in the visual layout of a page |
GUI Workflow Builder | Perform actions via point-and-click simulation |
Canary Recorder Plugin | Record a browser session and replay it |
🚀 Why CloudWatch Canaries?
Canaries are automated scripts that mimic user behavior to continuously monitor applications. They run periodically and report:
- HTTP status codes
- Load times
- Screenshot snapshots
- Errors or failures in reaching endpoints
✅ Benefits:
- Early detection of outages
- Blackbox synthetic monitoring
- Built-in integration with CloudWatch Metrics and Alarms
- Integration with Slack, SNS, PagerDuty, etc.
🧰 Canary Blueprint: Heartbeat Monitoring
I chose the Heartbeat Monitoring blueprint for the following reasons:
- Simple "ping-style" check for any URL
- Takes the Screenshot of the website
- Lightweight and fast
- Great for public and internal endpoint monitoring
📊 Canary Output & Metrics
The heartbeat canary logs:
- HTTP status (e.g., 200, 500, 404)
- Response time
- Screenshot of the page
- Logs in S3
- Canary metrics in CloudWatch
Metrics like SuccessPercent
, Duration
, and Failed
are available for dashboards and alarms.
Manual steps to Create Canary in the AWS Console:
- Navigate to CloudWatch > Synthetics > Create Canary
- Choose Use a blueprint
- Select Heartbeat monitoring
- Enter:
- Name:
ecs-heartbeat-canary
- URL: ALB DNS (e.g.,
http://ecs-myapp-alb-12345.us-east-1.elb.amazonaws.com
) - Enable ✅ screenshots (optional)
- Name:
- Configure:
- Schedule: Every 1 minute
- Runtime:
syn-nodejs-puppeteer-3.5
- Execution role
- Artifacts bucket for logs
- (Optional) Set up CloudWatch Alarm for failures
🔐 IAM & Security
- The canary assumes a Synthetics Execution Role with permissions for:
- Writing logs to CloudWatch Logs
- Storing artifacts in S3
- Sending metrics to CloudWatch
Sample IAM permissions can be found here.
Project Repo
I have automated creation of canary via terraform code itself.
Check out the terraform/monitoring/
module in the repo.
📂 GitHub Repository: aquavis12/ecs-website-monitor
Monitoring Module - ⭐ The Star of the Show ⭐
- Creates CloudWatch Synthetics canary for website monitoring
- Uses custom script to check website availability and take screenshots
- Sets up S3 bucket for synthetics artifacts with proper security controls
- Configures CloudWatch alarms for availability monitoring
- Creates custom CloudWatch dashboards for visualization
- Provides end-to-end user experience monitoring through CloudFront
- Detects availability issues before your users do
- Captures screenshots for visual verification
- Measures critical performance metrics like response time
- Enables historical trend analysis
Feel free to ⭐ the above GitHub repo or connect with me on LinkedIn for more AWS & DevOps blogs.
📌 Conclusion
Using CloudWatch Canaries is one of the easiest ways to ensure your web applications is always available and healthy. It complements your infrastructure monitoring and gives proactive visibility into application-level issues before your users report them.
Top comments (0)