AWS just released CloudWatch Synthetic service a few days ago.
The tool is to help you setup monitoring tool that can load web page, take screenshot or send API calls with auth token etc. It is part of the whole CloudWatch toolset so you can get all the nice web UI for the metrics and logs
This new service is built on Google’s puppeteer tools
https://github.com/puppeteer/puppeteer
It is quite easy to setup, details can be found here:
Read more: Debugging with Amazon CloudWatch Synthetics and AWS X-Ray
From my experience these days trying to set it up for one of my customer. I found the service is quite easy to use and pretty powerful. Here are some of my findings:
Here is one of my script to monitor customer’s site. It simulates the login process and take screenshots before and after login.
var synthetics = require('Synthetics');
const log = require('SyntheticsLogger');
const pageLoadBlueprint = async function () {
// INSERT URL here
const URL = "https://example.com";
const username = "[email protected]";
const passwd = "@#^!abcd1234"
let page = await synthetics.getPage();
const response = await page.goto(URL, {waitUntil: 'domcontentloaded', timeout: 30000});
//Wait for page to render.
//Increase or decrease wait time based on endpoint being monitored.
await page.waitFor(10000);
await page.type('input[name="email"][type="text"]', username)
await page.type('input[name="password"][placeholder="Password"]', passwd)
try {
await synthetics.takeScreenshot("click", 'result');
} catch(ex) {
synthetics.addExecutionError('Unable to capture screenshot.', ex);
}
await page.click('span[class="sign-in-form__title"]')
await page.waitFor(10000);
await synthetics.takeScreenshot('loaded', 'loaded');
let pageTitle = await page.title();
log.info('Page title: ' + pageTitle);
if (response.status() !== 200) {
throw "Failed to load page!";
}
};
exports.handler = async () => {
return await pageLoadBlueprint();
};
I ran this Canary every 10 minutes so we can have a really good way to measure their site’s performance during the day.
The last thing to talks about is its pricing. Currently it’s $0.0012 per canary run (https://aws.amazon.com/cloudwatch/pricing/). So the Canary we setup will cost about $5 a month ( $0.0012 * 6 * 24 * 30). Not too bad :)
Hope this helps.
About me: I am an AWS certified DevOps Engineer and Solution Architect pro. I’m currently working for an AWS premium partner consulting company.
The blogs here are all my experience and my opinions. Hope you will find them helpful