Amazon CloudWatch Synthetics enables you to create canaries to monitor your endpoints and your APIs.
Canaries are configurable scripts that follow the same routes and perform the same actions as
your customers. Canaries enable you to continually verify your customer experience, even
when there is no customer traffic on your applications. This lets you discover issues before your customers
do and react quickly to fix them. Common applications include monitoring for page load errors,
load latency for UI assets, broken or dead links, complex wizard flows, or checkout flows in your webpages.
I'll demonstrate how to use CloudWatch synthetics by creating a canary that monitors the availability
of the amazon.com retail website. First, I'll browse to the CloudWatch web console, then to the
CloudWatch Synthetics page. I'll choose "Create canary", then select the "Use a blueprint" option.
Synthetics blueprints allow me to quickly create canaries for common tasks, like loading a webpage,
checking for broken links, or simulating user actions. I could also write my own canary script and upload it here,
or could import it from an Amazon S3 bucket. Because I want to monitor the availability of a website, I'll select
the heartbeat monitoring blueprint. This blueprint will periodically load a single URL to check the availability
and latency of a website, and will capture a screenshot of the UI.
I'll provide a unique name for the canary and the URL for the website (in this case, amazon.com).
I want to be certain that I own or have permission to monitor this website, because it might experience increased traffic
based on canary run frequency settings. I'll use the defaults for the remaining settings.
The resulting canary will run once every five minutes, will retain success and failure data for about a month,
and it will use a new IAM Role for execution. For this canary, I'll also create an alarm to let me know when there are any
availability issues. Once the canary has been created, I can update the alarm to take additional actions like
sending e-mail notifications. If I wanted to, I could also configure this canary to monitor a website inside a VPC.
Finally, I select "Create canary". Creating a canary takes about a minute, and includes creating the
necessary IAM Roles, the S3 bucket, configuring any alarms, creating Lambda Functions, and creating
CloudWatch Log Groups. When canary creation is complete, I'll go to the canary's detail page. Note that it might take some
time for canary run results to be populated, depending on configuration and the frequency the canary is executed.
Here, I can view the details of a particular test run, including a graph of run results, the associated screenshot,
HAR file, and logs. Screenshots show how my customers view my webpages. The HAR (or HTTP ARchive),
can be used to view detailed performance data about the webpages. I can analyze the list of web requests and
catch performance issues like time to load for an item. Log files show the record of interactions between the canary run
and the webpage, and can be used to identify details of errors. Next, I'll create a canary that searches for broken links on my
website. I'll start by returning to the canaries page and select "Create canary" as before.
I'll use a Synthetics blueprint again, but this time, the broken link checker blueprint. A canary created with this
blueprint will do a basic web crawl on the URL provided, and will return the first broken link found.
Like before, I'll provide a unique name for the canary, and the endpoint URL to use. Then, I'll specify the maximum number
of links the canary should check. And, like the previous canary, this will create a canary that runs every five minutes,
retains success and failure data for a month, and uses a new IAM Role for execution.
On the canary details page, I can view the details of each test run, including the results for each of the
URLs that were checked. If the canary finds any broken links, I can investigate further and remedy.
CloudWatch Synthetics supports monitoring your endpoints every minute 24/7 and alerts
you when your application endpoints don't behave as expected. You can use CloudWatch Synthetics
to monitor your REST APIs, URLs, and website content, and perform checks for unauthorized
changes from phishing, code injection, and cross-site scripting.
For more information, visit the Amazon CloudWatch product page.