Leveraging Amazon CloudWatch Synthetics for Improved Application Monitoring

May 17, 2023
/
Lingaswamy Ravula
/
No items found.

Amazon CloudWatch Synthetics is a new AWS feature that allows you to monitor your application endpoints more accessibly and clearly. It collects canary traffic, which can continually verify the customer experience even when there is no incoming traffic from customers on your application. This makes it easier for you to trace and identify problems, and debug them more efficiently before they impact your customers.

CloudWatch Synthetics supports URL, REST API, and website content monitoring; checking for unauthorized changes from phishing, code injections, and cross-site scripting.

Optimize Built-In Alerting with CloudWatch Synthetics

CloudWatch Synthetics keeps running tests on your applications’ endpoints 24x7. The feature alerts you when the endpoints don’t behave as expected. Tests can be customized to check for the following in your applications:

  • Latency
  • Availability issues
  • Transactions
  • Page load errors
  • Broken/dead links for UI assets
  • Checkout flows
  • Complex wizard flows

You can also use the feature to isolate any endpoints that are very alarming and map them back to underlying infrastructure issues to reduce the mean time to resolution. 

Using Amazon CloudWatch Synthetic Canaries

In the same manner that miners used to carry canaries down coal mines to alert them of any issues such as toxic gases, Amazon CloudWatch canaries can highlight problems for you in your cloud environments. 

Canaries are configurable scripts that mimic the same patterns/actions and map the same traffic routes as a customer. In doing so they are improving the level of monitoring for your endpoints and APIs. This provides you with a bird’s eye view of what your customers experience when they interact with your environments. Canaries check the availability and latency of your endpoints, and can store load time data and screenshots of the UI. They also highlight your service’s availability from their point of view. 

You can run a canary just once or more often, on a regular schedule. Schedule canaries 24 hours a day even, as regularly as once per minute if you prefer. 

Integration with Amazon CloudWatch ServiceLens

CloudWatch Synthetics integrates well with Amazon CloudWatch ServiceLens. ServiceLens complements CloudWatch’s capabilities with AWS X-Ray to provide an end-to-end view of your services. It will help you to efficiently identify performance bottlenecks and identify any impacted users.

Canaries that are created with CloudWatch Synthetics appear on the Amazon CloudWatch ServiceLens service map. 

Using Amazon CloudWatch Synthetics 

Log in to the AWS Console. Under the “Services” tab, you will find Amazon CloudWatch; it is part of “Management and Governance”, click on it to get started.

#AmazonCloudWatch

In the CloudWatch Dashboard, then select “Synthetics”

#CloudWatchalarms

There is an orange button on the right side of the page, “Create canary”

Click on this to begin creating a canary for your cloud environments.

#canarysynthetics

Now you will be offered three different options for creating your first canary:

  • Use a blueprint
  • Upload a script
  • Import from S3

We will be using a blueprint in this example.

#createcanary

There are many different blueprints options, we are going to use Heartbeat monitoring. This basically tells the system being monitored to send an "I'm still here and I’m okay" message at specific intervals. Just like a chirping canary would in a coal mine.

#canaryheartbeatmonitoring

Next, name your canary, we have titled ours, ‘ibexlabs’.

Then identify your URL, we have provided our company’s URL in the example below.

#canarybuilder

If we want to edit the canary script in anyway, we can do so here. 

#canaryscripteditor

Now, we can schedule the canary in 2 different ways:

  • To run once

OR

  • To run continuously
  • Once per minute
  • Once per 5 minute
  • Once per hour
  •  
#schedulecanaries

To store the failure canary data, we create a retention period. Here, we have set a retention period of 31 days (~1 month) to store the data that failed so that we can act on it as necessary.

#dataretention1

Next, we also set a similar retention period to store successful canary data.

#dataretention2

All canary data is configured to store securely in one of our S3 buckets, which will be created automatically if we don’t specify one.

#datastorage

Now, we can enable also thresholds for our canaries by clicking on ‘thresholds’.

#thresholds1

Next click on ‘edit’.

#thresholds2

And finally enabled them here.

#canarythresholds

When creating a canary we need to configure an IAM role, as per the screenshot we can choose which option we prefer below.

#IAMcreatenewrole

Finally, after we create our canary, we receive the status results below, which indicate whether the tests passed or failed.

#canariespassedorfailed

By reviewing the duration of time that the canary tests have been running over, we can also check the status.

#canarytestruns
#canaries

And here we can see which status checks passed and which failed.

By enabling these two features, Amazon CloudWatch Synthetics and Amazon CloudWatch ServiceLens, you can continually improve your customer experience even when you don't actually have any customer traffic on your applications. Get ahead of the game by discovering issues before your customers do.

Ibexlabs is an experienced DevOps & Managed Services provider and an AWS consulting partner. Our AWS Certified DevOps consultancy team evaluates your infrastructure and make recommendations based on your individual business or personal requirements. Contact us today and set up a free consultation to discuss a custom-built solution tailored just for you.

Lingaswamy Ravula

Lingaswamy is a DevOps Engineer at Ibexlabs. He is passionate about finding solutions to make applications highly available, secure, and fault tolerant.

Talk to an Ibexlabs Cloud Advisor