Amazon CloudWatch Review and Tutorial

Large companies are all moving their applications to the cloud. Medium and small ones are following suite. Are you one of them?

But moving to the cloud is not enough! You need to ensure that the cloud resources and services are continuously available to ensure that the applications you are moving to the cloud are available to your customers.

In essence, cloud services should not be disabled. That’s detrimental to business.

But how do you ensure that cloud services are not disabled? You will need a tool for monitoring those applications you are moving to the cloud.

Amazon CloudWatch is one such application.

Did you think Amazon CloudWatch was some smartwatch like Apple Watch?

Ha, ha! Many people think the same! It’s fine. You don’t need to know everything in advance. Learn things when you need to learn them.

Now that you know what Amazon CloudWatch is, here is a simple question that needs to be answered.

Trust me, this is where you will decide where you need to read the entire article, or you can just happily ignore it.

Here is the question:

‘Do you need Amazon CloudWatch if your WordPress site is hosted on Amazon cloud server?’

The answer – No you don’t!

If you are reading this article just to learn how to monitor your website’s uptime, there are simpler tools. Something as simple as Jetpack can do this for you.

Are you beyond WordPress or simple websites?

If so, I believe you are still reading this.

That’s great!

Here is a simple thing you need to know – Amazon CloudWatch is for enterprise-grade applications running on the cloud. It is not for average Joes like you and me.

AWS CloudWatch is used for monitoring applications and other resources that are running on the AWS platform. This tool will collect operational data through logs, metrics, and events that together provide a unified view of AWS applications and resources.

Now that you have a better idea about Amazon CloudWatch, let’s go through the tutorial.

But…

Don’t expect too much out of it. It is not going to give you a hands-on training. You need to an AWS administrator if you want to use AWS CloudWatch. That requires in-depth knowledge of AWS.

This writeup is going to touch only the basics to give you a fair idea. That’s all!

Let’s begin…

In this tutorial and review:

  • What is Amazon CloudWatch?
  • How does CloudWatch work?
  • Why do you need CloudWatch?
  • Advantages of using CloudWatch.
  • Creating CloudWatch dashboards.
  • Creating and configuring CloudWatch alarms.

Let’s start with each topic.

What is Amazon CloudWatch?

Amazon CloudWatch is an AWS component. It allows you to monitor AWS resources like EC2 instances, load balancers, elastic, auto-scaling groups, etc. You can also monitor other AWS services like RDS, SQS, SNS, and Amazon S3.

To use Amazon CloudWatch, you need to be an AWS administrator. If your role is anything below the administrator, it will be safe to assume that you don’t have a thorough knowledge of AWS. This will make you unfit for using CloudWatch.

CloudWatch is an advanced tool that will allow you to monitor several AWS applications and instances from one centralized dashboard.

When you start using CloudWatch, you can do the following:

  • Detect any anomaly in the cloud environment setup that you are using.
  • Create a custom dashboard that will show you metrics of all the AWS services that you are using.
  • Create alarms and configure them to monitor AWS metrics, and even trigger automatic actions.
  • Clearly understand how your applications are performing, how much of AWS resources you are using, and the overall health of all your operations.

You get it, right? CloudWatch is not only a complex tool, but an incredibly powerful one. It is not something you use for monitoring a blog.

How does CloudWatch Work?

There are four primary functions of CloudWatch. They are:

  1. Collecting metrics and logs.
  2. Monitoring and visualizing the collected data.
  3. Trigger automatic response to any change.
  4. Analyzing your metrics.

What on Earth do these things mean?

Let’s find out!

Collecting metrics and logs

CloudWatch will retrieve or collect metrics and logs from all AWS services you are using. All the metrics are stored in the repository, including any custom metrics that you enter the repository.

There various AWS services that publish CloudWatch metrics. For instance, if you are using Amazon CloudFront, or Amazon Athena, or AppStream version 2.0, Amazon API Gateway, etc. – CloudWatch will get metric from all of them.

Monitoring and visualizing the collected data

What happens to the collected data? CloudWatch will visualize the data using CloudWatch dashboards where you can get a unified view of every AWS application, server, and resource that you are using. It doesn’t matter whether you are running them on the cloud or in premise.

The visual presentation will allow you to perform visual analysis, and help you learn how the resources are currently performing. You will get to know the overall health of your operations.

Trigger automatic response to any change

Once CloudWatch finds any operational changes, it will automatically trigger a response using alarms. You need to set the alarms.

For instance, you can trigger an automatic restart or an automatic termination of EC2 instances if a certain set of conditions are fulfilled.

Not just that, you can even set alarms for automatic triggering of Amazon SNS or Amazon EC2 auto-scaling.

The response that CloudWatch will trigger will depend on the alarm your set and configure.

We will learn about creating and configuring alarms later in this article.

Analyze your metrics

This is the last step where you will analyze and visualize the data you collect. The analysis will help you get a clear insight into your application’s performance.

You can use CloudWatch Metric Math for real-time analysis. This will help you understand your data deeply, and take necessary actions.

Why do you need CloudWatch?

Will your organization like to have an application that doesn’t perform optimally? While it is necessary to have both web-based and cloud-based applications, it is also necessary to have a handy monitoring tool capable of monitoring networks, infrastructure, and cloud platforms.

Suppose you have a web application that you have deployed on the cloud. Don’t you want to know the answers to these questions:

  • How much bandwidth is your application consuming every day?
  • How many users are using your application?
  • How is your application performing on the cloud?
  • Are you customers satisfied using your application, or are they dissatisfied?

CloudWatch will give you answers to all these questions. It will help you track the performance of your application on the cloud.

With the data that CloudWatch will put at your disposal, you can identify the bottlenecks (if any) that are impacting (or can potentially impact) the performance of your application.

Once you identify such bottlenecks, you can quickly eliminate them to improve your application’s performance. The better your application performs, the more your business grows.

AWS is growing complex and complex by the day. It is reached a point where manual monitoring of every application and resources you use is virtually impossible. CloudWatch, which is essentially an automation tool helps you to monitor everything in one place. That’s the reason why you need CloudWatch.

Advantages of using CloudWatch

If you start using CloudWatch to monitor your applications and cloud infrastructure, you can enjoy at least 5 benefits. They are:

1. A single point of monitoring – a unified dashboard

Amazon CloudWatch enjoys native integration with 70+ AWS-related services. This means that you get to monitor all of those (if you use all of them) in a single place.

The amount of data generated by cloud-based applications is enormous. Being able to collect data from all applications in a single place via metrics and logs paves the way for easy integration of the data with all your applications.

Being able to visualize the data allows for easy analysis of the applications running of AWS cloud. This in turn ensures that you can keep your application free of errors and bottlenecks.

2. Allows optimization of resources and improvement of operational efficiency

With CloudWatch, you can get real-time insights that allow optimizing operational efficiency. When efficiency increases, cost reduces!

Using CloudWatch you can understand the type of workload capacities you will need for your application to perform without flaws.

Because CloudWatch allows setting and customizing alarms, you can always achieve automation in actions using predefined thresholds. You can even use machine learning algorithms to detect anomalies and take actions accordingly.

3. Get granular data from AWS as well as on-premise applications

Because CloudWatch natively integrates with 70+ AWS services, CloudWatch can collect metric data and publish them automatically.

The amount of detailed data you can get is baffling. You can get 1-minute native and customized metric with one second granularity.

That kind of data will help you to drill down deeper and deeper to find out everything you need to know about your application’s performance.

What else?

CloudWatch natively supports hybrid AWS architecture that uses both cloud-based resources and on-premise resources. So, if your application is using hybrid architecture, you can still benefit from CloudWatch.

4. Increased operational visibility

CloudWatch can gather data across your applications, infrastructure stacks, networks, and other AWS services that you might be using.

This allows for better optimization of applications.

For instance, CloudWatch can clearly tell you how much memory your application is consuming or how much bandwidth it is using every day. If things don’t seem right, you can go ahead and optimize your application to minimize the usage as much as possible.

Did you know that with CloudWatch data you can perform metric-related mathematical operations? Such mathematical calculations can help you get amazing insights.

Suppose you have several EC2 instances. With CloudWatch data, you can get the aggregate of the memory usage across all instances. This will make your entire system visible right in front of you. If you detect any performance issues, you can resolve them promptly.

5. Get valuable insights

CloudWatch generates logs of different applications and AWS services. By analyzing and exploring the logs you can monitor things like capacity usage, CPU utilization, memory usage, etc.

As far as payments are concerned, you need to pay only for log queries you conduct with CloudWatch. Log queries can also scale up depending on the complexity and the volume of your logs.

Creating CloudWatch Dashboards

You can customize the CloudWatch dashboards to get a unified view of all AWS resources you are using irrespective of the regions.

CloudWatch will allow you to create as many dashboards as you want. There are two ways to create a CloudWatch dashboard, and they are:

  • CloudWatch Console
  • PutDashboard API

Here’s how you create a dashboard using CloudWatch Console:

Step 1: Open the CloudWatch Console.

Step 2: In navigation pane: Dashboards >> Create Dashboard.

Step 3: Enter dashboard name in the ‘Create New Dashboard” box that will show up. Enter the name for your dashboard and then click on the Create Dashboard button.

Note: In case you name your dashboard as ‘CloudWatch-Default,’ the dashboard you create will start showing on the homepage of CloudWatch. If you slightly modify the dashboard name to ‘CloudWatch-Default-,’ the dashboard will show up on the homage of CloudWatch only and only when you open the particular resource group of AWS.

Perform whatever you need.

Step 4: After you create the dashboard, you will have to add something to the dashboard. You will see an action box that reads ‘Add to this dashboard.’

You can add whatever you want.

Adding a graph

If you want to add a graph, you need to select the Stacked or Line Area and then click on the configure option.

You will get a dialog box called ‘Add metric graph.’ You need to choose the metric that you want to include in the graph. After you select the metric, click on ‘Create widget.’

Adding a number to display a metric

You may want to add a number for displaying a metric. To do that, select Number, and then click on the configure option.

Select the metrics that you want to include in the graph by using the ‘Add metric graph’ dialog box that appears. Now, click on the ‘Create widget’ option.

Adding a text block

If you want to add a text block, you can do that as well. Just select Text and then click on the configure option.

Once you do that, a new dialog box called ‘New text widget’ will show up. Select Markdown and then add your text. Don’t forget to format you text.

Finally, click on the ‘Create widget’ option.

Step 5: If you want to add more widgets, do that and then, save your dashboard.

That’s it!

Explain how to create a dashboard using PutDashboard API function is beyond the scope of this article. So, I will skip it. However, here are a couple of common parameters that are extensively used:

  • DashboardName: this will specify the name of your dashboard in string format. It is a mandatory field.
  • DashboardBody: this will specify all the information your dashboard will hold including the widgets you want on the dashboard, and their position on the dashboard.

Creating and configuring CloudWatch alarms

You can create two types of alarms:

  • Metric alarms
  • Composite alarms

Metric alarm will be monitoring only one metric or a math metric based on a mathematical expression.

Composite alarm, on the other hand, will trigger, if and only if the conditions you set for all other alarms you configured are satisfied.

CloudWatch will also allow creating an alarm based on:

  • Metric math expression.
  • Anomaly detection.
  • A single metric’s static threshold.

Here is a step-by-step guide for setting up a CloudWatch alarm:

Creating alarm based on single metric

Step 1: From the navigation pane of the CloudWatch Console, click Alarms >> Create Alarm.

Step 2: Select the metric that you want and then do either of the two:

  • In the search box, search for a metric and hit the enter button.
  • Find and select the service namespace that contains the metrics you want to be included in the alarm.

Step 3: Switch to the ‘Graphed metrics’ tab and do the following:

  • From Statistics, choose any one from the available percentiles or statistics.
  • From Period, specify the alarm’s evaluation period.
  • Click on the ‘Select metric’ option to pull up the page called ‘Specify metric and conditions.’ This page is where you find all the information of the statistics and metrics specified by you.

Step 4: Switch to the ‘Conditions’ tab and do the following:

  • Give your alarm a name and description.
  • Define the metric’s threshold value using the ‘Whenever is’ field.
  • Click on the option which reads ‘Additional configuration.’
  • Define the number of data points or evaluation points in the ‘Datapoints to alarm’ field. This is the value required for triggering the alarm.
  • In the case of missing data points, use the ‘Missing data treatment’ for configuring your alarm settings, and then click on the Next button.

Step 5: Switch to the ‘Notification’ tab and select the Amazon SNS topic.

Step 6: If you want the alarm to perform specific EC2 actions (like auto scaling), select the appropriate options.

Step 7: Switch to ‘Preview and create’ tab. This is where you can preview all the settings. If you are happy, click on the ‘Create alarm’ option.

That’s all! You have successfully created an alarm.

Creating alarm based on anomaly detection

Step 1: Perform steps 1, 2, and 3 mentioned above for single metric-based alarm creation.

Step 2: Switch to ‘Conditions’ tab and do the following:

  • Select the option ‘Anomaly detection.’
  • Specify the metric value range that can trigger an alarm in the ‘Whenever is’ field.
  • In the ‘Anomaly detection threshold’ field, specify the number for anomaly detection.
  • Click on the ‘Additional configuration’ option.
  • Specify the number of data points or evaluation points (required for triggering the alarm) in the ‘Datapoints to alarm’ field.
  • Configure alarm settings from ‘Missing data treatment’ if data points are missing, and then click on the Next button.

Step 3: Repeat steps 5, 6, and 7 mentioned above for single metric-based alarm creation.

Creating alarm based on metric math expression

Step 1: Perform steps 1, 2, and 3 mentioned above for single metric-based alarm creation.

Step 2: Add a new row for expression by clicking on ‘Add a math expression.’

  • In the ‘Details’ column of the new row, add a math expression.
  • In the ‘Id’ column, add another mathematical expression or a metric.

You can add more math expressions if you need.

Step 3: Display the ‘Specify metric and conditions’ page by clicking on ‘Select metric.’ The page will display all information of metric math expression that you selected.

Step 4: Switch to ‘Conditions’ tab and perform everything mention in the Step 2 of alarm creation based on anomaly detection.

Step 5: Repeat steps 5, 6, and 7 mentioned above for single metric-based alarm creation.

Pros and Cons of Amazon CloudWatch

Pros of Amazon CloudWatch

  • Allows monitoring all applications across 70+ AWS services.
  • Gives granular data for detailed analysis.
  • Allows visual analysis of all data in a single unified dashboard.
  • Easily manages log periods.
  • Saves time and money.
  • Offers real-time monitoring.
  • Allows creating alarms based on custom triggers.
  • Pay for what you use.

Cons of Amazon CloudWatch

  • Requires extensive knowledge of AWS.
  • Better handled by AWS administrators than rookies.
  • Enterprise-grade tool not suitable for beginners, and small website owners.
  • Works only with AWS services. Cannot be used with other cloud platforms.

Conclusion

Amazon CloudWatch is an extremely powerful tool for monitoring your cloud applications and cloud resources offered by AWS. Unfortunately, it is not for everyone.

To even deploy CloudWatch, let alone, using it, one needs to have an extensive knowledge of AWS.

For rookies and small blog owners using AWS hosting services, CloudWatch is nothing short of a distant dream that only gods can dare to see. It is literally meaningless for small blogs and websites.

If someone knows exactly what they are dealing with Amazon CloudWatch can be a lifesaver

Scroll to Top