AWS Infrastructure Monitoring — Quick and Easy

Arvind Telharkar
2 min readMay 12, 2022

--

Monitoring your services in production is a must for most serious businesses. People who develop on AWS, typically use AWS Cloudwatch for setting up monitoring. Typical metrics to monitor are latency, faults, invocations, throttles etc.

Monitoring doesn’t come into picture until the service is nearly built or nearing completion. It doesn’t even make sense to have a monitoring setup in place before the service is built. As a result, many people find it taxing to set it up, especially after they are done building the meat of their service. Why is that so? — There is a good reason! Setting up monitoring involves a significant investment in time. There is no excuse when it comes to setting up monitoring for your AWS service.

Photo by Adam Nowakowski on Unsplash

CDK monitoring constructs

Thankfully, there is this library called CDK monitoring constructs! This library can get monitoring up and running for your AWS infrastructure within minutes! You don’t have to spend days setting it up, building every pixel of those CloudWatch dashboards yourself! This library is a game changer! The repository can be found on github here. The following are the major advantages of using this library for monitoring AWS infrastructure —

1. Boilerplate metrics for every AWS service

When you create your monitoring setup for any AWS service, you have certain key metrics in your mind. For e.g., if you want to monitor AWS Lambda, you want to look at latency, faults, invocations and maybe throttles. For monitoring an EC2 instance, you might want CPU utilization, disk related metrics etc. CDK monitoring constructs does that for you by providing a simple abstraction. For each AWS service in your infrastructure, you can create alarms and dashboards in CloudWatch using just a few characters!

All you have to do is set up a monitoring facade object — and then the fun begins!

const monitoring = new MonitoringFacade(this, "monitoring", {
alarmFactoryDefaults: {
// default props for alarms
},
// other props
});

Next, for monitoring a lambda function which you have, you just need to do the following —

monitoring.monitorLambdaFunction(lambda);  // Just an example.

You can also override existing default configuration.

2. Single place for all monitored metrics

For a single service, you don’t want to scatter your monitoring code all over the place. Given your EC2 monitoring setup, you want to get a quick overview of what is being monitored for EC2 as far as your infrastructure is concerned. This is especially useful when you make customizations to your alarms and dashboards!

3. Custom metrics

You can also set up custom metrics with a simple call to

.monitorCustom()

With this library, you can have a working CloudWatch dashboard and alarms set up for all of your AWS services in less than an hour! I would highly recommend this library to anyone who is new to CDK or AWS.

--

--