CPU Utilization graph

CloudWatch is AWS’s monitoring tool. It collects data about the health and usage of all of your AWS services, and allows you to display them on graphs and in custom dashboards, and set alarms when unusual spikes happen.

Is CloudWatch Free?

CloudWatch is included as part of AWS’s free tier. The free tier only lasts a year, but CloudWatch is part of the “Always Free” tier, so you won’t have to worry about paying for it.

It does cost money if you go out of the free tier limits—you’re limited to 3 dashboards, 10 alarms, and 5 GB of logs ingested. AWS says that most applications should be able to operate within the free tier limits with basic monitoring.

If you want more in-depth monitoring, you can enable detailed monitoring for certain metrics, which update every minute rather than every 5 minutes. You’re allowed 10 of these under the free tier, after which you’ll have to start paying for them.

How to Get Started

Head over to the CloudWatch Management Console, and select “Metrics.” If you’ve been using other AWS services, there should be metrics already available. If not, you may have to wait a day or so for them to appear. If you want to ingest logs, you’ll have to install the CloudWatch logs agent on your EC2 instances.

CloudWatch log

Metrics are organized by service; for instance, there are separate metrics for EBS and EC2. You can select metrics to display them on the graph. For EC2, the “CPUCreditUsage” metric shows the benefit of burstable instances; a mostly idle instance spikes up when requests are made, and accumulates CPU credits when idle.

CPUCreditUsage metric.

You can graph multiple metrics on the same graph, and hover over them to view more information and isolate the metric from the others:

Graph of multiple metrics on the same graph.

You can give your graph a name and labels under “Graph Options,” and under the “Source” tab, you can copy the graph as JSON (for use later in dashboards).

Copying a graph for later usage.

Doing Math with Metrics

CloudWatch can do more than display simple metrics on graphs. If you select “Graphed Metrics,” there’s a button to add a composite metric, which is formed from a math expression:

Select "Graphed Metrics" to add a button to add a composite metric, which is formed from a math expression.

The metric math is a bit unwieldy to use, but AWS documents it extensively. You can use any arithmetic operator, as well as functions like SUM, MIN, and MAX. One thing to note is that to display the function as a time series on the graph, you’ll need to use the METRICS function.

Assembling Your Dashboard

You get three of these for free, so you may as well use them. Head over to the dashboard tab and create a new dashboard. Next, click the “Add Widget” button, and you’ll be presented with a few options.

Widget options.

Line chart will work best with most metrics, unless you want single-value numbers, which can be useful on a dashboard for certain things like current balances.

You’ll be asked to configure your widget; you can do your configuration in here, or paste in JSON from a preconfigured widget.

Configure your widget.

Once the widget is added, you can drag it around, resize it, and position it where you would like:

Adjusting the time scale will adjust the time scale for all graphs and press "Save Dashboard" to apply your changes.

Adjusting the time scale will adjust the time scale for all graphs in the dashboard. Once you’re done, press “Save Dashboard” to apply your changes.

Setting Alarms

Alarms are one of CloudWatch’s more useful features. They will notify you of any unexpected behavior even while you’re not watching the dashboard. To get started, go to the “Alarms” tab in the sidebar and create a new alarm. You get 10 of these within the free tier.

Select a metric, then you’ll have to define what exactly is unexpected behavior. For example, if you wanted to monitor a T2 instance’s CPU credit usage, you could define “unusual” as getting close to running out of CPU credits.

Select a metric, then define what exactly is its unexpected behavior.

You can define the line or a band as the threshold, and AWS will perform an action when one datapoint crosses over the threshold. This can be something as simple as sending you a notification using their SNS service, or it can be something more proactive such as scaling up an Auto Scaling group to meet demands, or rebooting a troublesome EC2 instance automatically.

Profile Photo for Anthony Heddings Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon's AWS platform. He's written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times.
Read Full Bio »