You can use Amazon CloudWatch Synthetics to create canaries, configurable scripts that run on a schedule, to monitor your endpoints and API operations. Canaries follow the same routes and perform the same actions as a customer, which makes it possible to continuously verify your customer experience even when you don’t have any customer traffic on your applications. By using canaries, you can discover issues before your customers do.
If your canary uses
syn-nodejs-puppeteer-3.1 or later runtime version, you can use the Heartbeat monitoring blueprint and batch multiple URLs in a single canary versus using multiple canaries to monitor a single URL. You can then see the status, duration, associated screenshots, and failure reason for each URL in the step summary of the canary run report. As CloudWatch Synthetics is priced on canary runs, batching multiple URLs in a single canary also reduces your costs. Check Pricing section of this blog post for additional details.
In this blog post, I present the value proposition for batching multiple URLs in a single canary. For the purposes of this blog post, my canaries monitor multiple URLs as shown in Figure 2.
Figure 1 shows the Create canary page in the CloudWatch console. To use Heartbeat monitoring blueprint to monitor multiple URLs, complete the fields as shown in the Figure 1. Once you fill the necessary fields in the page, click on Create canary button in the bottom of the page.
Figure 1: Create canary page
Select the canary from the canaries list page and navigate to the canary details page. You should see that the canary is in
Running state. Click on Availability tab to view information about the recent runs of this canary. Figure 2 shows the step summary of the canary run report in the CloudWatch console.
Figure 2: Step summary of the canary run report
If you’re monitoring multiple URLs in Heartbeat monitoring blueprint:
- Canaries that use either the
executeHttpStep()methods from the Synthetics library also publish
Durationmetrics with the dimensions
StepNamefor each step.
- For canaries that use
syn-nodejs-pupeteer-3.1or later, the
setConfigsupport multiple Boolean parameters that determine which metrics are published by the canary. For more information, check Library functions available for Node.js canary scripts and SyntheticsConfiguration class in the Amazon CloudWatch User Guide. As you see fit, disable relevant parameters in the
setConfigto save costs.
In the following example,
setConfig allows all steps to run even if some fail. It disables taking screenshot on step start.
Your monthly bill varies depending on number of canary runs, AWS Lambda charges, monitoring and storage configuration of the canary. Note that CloudWatch Synthetics publishes
Duration metrics for the overall AWS account, each canary, and each step. Each canary run also runs Lambda function and writes logs and results to CloudWatch Logs and to the designated Amazon Simple Storage Service (Amazon S3) bucket. For more information, check the Lambda, Amazon S3, and CloudWatch Logs pricing pages.
To avoid charges to your account, remove the resources you created.
- In the Amazon CloudWatch console, choose the canary you created and from Actions, choose Stop.
- Choose the canary again and from Actions, choose Delete.
When you delete a canary, the resources used and created by the canary are not deleted automatically. Also delete the following:
- (optional) In the Amazon CloudWatch console, delete the CloudWatch alarms created for this canary. These alarms have a name of
- In the Amazon CloudWatch console, delete the CloudWatch log groups created for the canary. These logs groups have the name
- In the AWS Lambda console, delete the Lambda function used by this canary. These have the prefix
- In the Amazon S3 console, delete the Amazon S3 objects and buckets created for this canary, such as the canary’s artifact location.
- In the AWS Identity and Access Management console, delete the IAM roles created for the canary. If they were created in the console, these roles have the name
I encourage you to use the information in this blog post and consider batching multiple URLs in a single canary using CloudWatch Synthetics. For more information, check CloudWatch Pricing and CloudWatch Service Quotas. If you have questions or feedback, open an AWS Support Case.