Amazon CloudWatch User Guide Cloud Watch

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 258 [warning: Documents this large are best viewed by clicking the View PDF Link!]

Amazon CloudWatch
User Guide
Amazon CloudWatch User Guide
Amazon CloudWatch User Guide
Amazon CloudWatch: User Guide
Copyright © 2016 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any
manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other
trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to,
or sponsored by Amazon.
Amazon CloudWatch User Guide
Table of Contents
What is Amazon CloudWatch? ........................................................................................................ 1
Architecture .......................................................................................................................... 1
Concepts ............................................................................................................................. 2
Metrics ........................................................................................................................ 3
Namespaces ................................................................................................................ 3
Dimensions .................................................................................................................. 4
Time Stamps ................................................................................................................ 6
Units ........................................................................................................................... 6
Statistics ...................................................................................................................... 7
Periods ........................................................................................................................ 7
Aggregation .................................................................................................................. 8
Alarms ......................................................................................................................... 8
Regions ....................................................................................................................... 9
Supported AWS Services ....................................................................................................... 9
Accessing CloudWatch ......................................................................................................... 13
Regions and Endpoints ........................................................................................................ 13
Limits ................................................................................................................................ 13
Related AWS Services ......................................................................................................... 14
Resources .......................................................................................................................... 15
Getting Set Up ............................................................................................................................ 17
Sign Up for Amazon Web Services (AWS) .............................................................................. 17
Sign in to the Amazon CloudWatch Console ........................................................................... 17
Set Up the Command Line Interface ...................................................................................... 19
Getting Started ........................................................................................................................... 20
Scenario: Monitor Your Estimated Charges Using CloudWatch ................................................... 20
Step 1: Enable Monitoring of Your Estimated Charges ...................................................... 21
Step 2: Create a Billing Alarm ....................................................................................... 21
Step 3: Check Alarm Status .......................................................................................... 25
Step 4: Edit a Billing Alarm ........................................................................................... 26
Step 5: Delete a Billing Alarm ....................................................................................... 26
Scenario: Publish Metrics to CloudWatch ................................................................................ 26
Step 1: Define the Data Configuration ............................................................................ 27
Step 2: Add Metrics to CloudWatch ............................................................................... 27
Step 3: Get Statistics from CloudWatch .......................................................................... 28
Step 4: View Graphs with the Console ........................................................................... 29
Using Dashboards ....................................................................................................................... 30
Create a Dashboard ............................................................................................................ 30
Add or Remove a Graph from a Dashboard ............................................................................ 31
Move or Resize a Graph on a Dashboard ............................................................................... 32
Edit a Graph on a Dashboard ............................................................................................... 32
Rename a Graph on a Dashboard ......................................................................................... 33
Add, Edit, or Remove a Text Widget from a Dashboard ............................................................ 33
Create a Cross-Region Dashboard ........................................................................................ 34
Switch Between Dashboards ................................................................................................. 34
Link and Unlink Graphs on a Dashboard ................................................................................ 34
Change the Dashboard Refresh Interval ................................................................................. 35
Change the Dashboard Time Range, Period, or Time Format ..................................................... 35
Viewing, Graphing, and Publishing Metrics ...................................................................................... 37
View Available Metrics ......................................................................................................... 37
AWS Management Console .......................................................................................... 37
Command Line Tools ................................................................................................... 38
Query API .................................................................................................................. 40
Search for Available Metrics ................................................................................................. 40
Select and Deselect Metrics ................................................................................................. 41
Get Statistics for a Metric ..................................................................................................... 44
iv
Amazon CloudWatch User Guide
Get Statistics for a Specific EC2 Instance ....................................................................... 44
Aggregating Statistics Across Instances .......................................................................... 48
Get Statistics Aggregated by Auto Scaling Group ............................................................. 53
Get Statistics Aggregated by Amazon Machine Image (AMI) ID .......................................... 55
Graph Metrics ..................................................................................................................... 60
Graph a Metric ........................................................................................................... 60
Graph a Metric Across Resources ................................................................................. 61
Graph Several Metrics ................................................................................................. 63
Modify the Date and Time on a Graph ........................................................................... 64
Modify the Statistic for a Graph ..................................................................................... 65
Modify the Period for a Graph ....................................................................................... 66
Modify a Graph's Title .................................................................................................. 67
Create an Alarm from a Metric on a Graph ..................................................................... 68
Zoom in to a Graph ..................................................................................................... 69
Switch the Y-Axis for a Metric ....................................................................................... 70
Set custom bounds for the Y-Axis on a graph .................................................................. 71
Save a Graph ............................................................................................................. 72
Publish Custom Metrics ........................................................................................................ 73
Publish Single Data Points ........................................................................................... 74
Publish Statistic Sets ................................................................................................... 75
Publish the Value Zero ................................................................................................ 75
Creating Alarms .......................................................................................................................... 76
Set Up Amazon Simple Notification Service ............................................................................ 78
AWS Management Console .......................................................................................... 78
Command Line Tools ................................................................................................... 79
Create or Edit an Alarm ....................................................................................................... 80
Send Email Based on CPU Usage Alarm ................................................................................ 82
AWS Management Console .......................................................................................... 82
Command Line Tools ................................................................................................... 84
Send Email Based on Load Balancer Alarm ............................................................................ 84
AWS Management Console .......................................................................................... 84
Command Line Tools ................................................................................................... 86
Send Email Based on Storage Throughput Alarm ..................................................................... 86
AWS Management Console .......................................................................................... 86
Command Line Tools ................................................................................................... 88
Create Alarms That Stop, Terminate, Reboot, or Recover an Instance ......................................... 88
Adding Stop Actions to Amazon CloudWatch Alarms ........................................................ 90
Adding Terminate Actions to Amazon CloudWatch Alarms ................................................. 91
Adding Reboot Actions to Amazon CloudWatch Alarms ..................................................... 93
Adding Recover Actions to Amazon CloudWatch Alarms ................................................... 95
Using the Amazon CloudWatch Console to View the History of Triggered Alarms and
Actions ...................................................................................................................... 97
Amazon CloudWatch Alarm Action Scenarios .................................................................. 97
Monitor Your Estimated Charges ......................................................................................... 101
Enabling the Monitoring of Your Estimated Charges ........................................................ 102
Creating a Billing Alarm .............................................................................................. 103
Editing a Billing Alarm ................................................................................................ 107
Checking Alarm Status ............................................................................................... 108
Deleting a Billing Alarm .............................................................................................. 108
Logging API Calls ...................................................................................................................... 110
CloudWatch Information in CloudTrail ................................................................................... 110
Understanding Log File Entries ............................................................................................ 112
Monitoring Memory and Disk Metrics ............................................................................................ 115
Prerequisites ..................................................................................................................... 116
Getting Started .................................................................................................................. 117
Using the Scripts ............................................................................................................... 118
mon-put-instance-data.pl ............................................................................................. 118
mon-get-instance-stats.pl ............................................................................................ 121
v
Amazon CloudWatch User Guide
Viewing Your Custom Metrics in the AWS Management Console .............................................. 122
Authentication and Access Control ............................................................................................... 123
Authentication ................................................................................................................... 123
Access Control .................................................................................................................. 124
Overview of Managing Access ............................................................................................. 125
Resources and Operations .......................................................................................... 125
Understanding Resource Ownership ............................................................................. 127
Managing Access to Resources ................................................................................... 127
Specifying Policy Elements: Actions, Effects, and Principals ............................................. 128
Specifying Conditions in a Policy ................................................................................. 128
Using Identity-Based Policies (IAM Policies) .......................................................................... 129
Permissions Required to Use the CloudWatch Console ................................................... 129
AWS Managed (Predefined) Policies for CloudWatch ...................................................... 132
Customer Managed Policy Examples ............................................................................ 132
Amazon CloudWatch Permissions Reference ......................................................................... 134
Namespaces, Dimensions, and Metrics Reference .......................................................................... 140
AWS Namespaces ............................................................................................................. 141
Amazon API Gateway Dimensions and Metrics ...................................................................... 142
API Gateway Metrics ................................................................................................. 142
Dimensions for Metrics ............................................................................................... 143
Auto Scaling ..................................................................................................................... 144
Auto Scaling Group Metrics ........................................................................................ 144
Dimensions for Auto Scaling Group Metrics ................................................................... 144
AWS Billing and Cost Management ...................................................................................... 144
AWS Billing and Cost Management Metrics ................................................................... 145
Dimensions for AWS Billing and Cost Management Metrics .............................................. 145
Amazon CloudFront ........................................................................................................... 145
Amazon CloudFront Metrics ........................................................................................ 145
Dimensions for CloudFront Metrics ............................................................................... 146
Amazon CloudSearch ......................................................................................................... 146
Amazon CloudSearch Metrics ...................................................................................... 147
Dimensions for Amazon CloudSearch Metrics ................................................................ 147
Amazon CloudWatch Events ............................................................................................... 147
CloudWatch Events Metrics ........................................................................................ 147
Dimensions for CloudWatch Events Metrics ................................................................... 148
Amazon CloudWatch Logs .................................................................................................. 148
CloudWatch Logs Metrics ........................................................................................... 148
Dimensions for CloudWatch Logs Metrics ...................................................................... 149
Amazon DynamoDB ........................................................................................................... 150
DynamoDB Metrics .................................................................................................... 150
Dimensions for DynamoDB Metrics .............................................................................. 160
Amazon ECS .................................................................................................................... 160
Amazon ECS Metrics ................................................................................................. 160
Dimensions for Amazon ECS Metrics ........................................................................... 161
Amazon ElastiCache .......................................................................................................... 162
Dimensions for ElastiCache Metrics .............................................................................. 162
Host-Level Metrics ..................................................................................................... 162
Metrics for Memcached .............................................................................................. 163
Metrics for Redis ....................................................................................................... 165
Amazon EBS .................................................................................................................... 167
Amazon EBS Metrics ................................................................................................. 167
Dimensions for Amazon EBS Metrics ........................................................................... 169
Amazon EC2 .................................................................................................................... 169
Amazon EC2 Metrics ................................................................................................. 169
Dimensions for Amazon EC2 Metrics ............................................................................ 172
Amazon EC2 Spot Fleet ..................................................................................................... 173
Amazon EC2 Spot Fleet Metrics .................................................................................. 173
Dimensions for Amazon EC2 Spot Fleet Metrics ............................................................. 174
vi
Amazon CloudWatch User Guide
Amazon EFS .................................................................................................................... 174
Amazon CloudWatch Metrics for Amazon EFS ............................................................... 174
Dimensions for Amazon EFS Metrics ............................................................................ 177
Elastic Load Balancing ....................................................................................................... 177
Application Load Balancer Metrics ................................................................................ 177
Metric Dimensions for Application Load Balancers .......................................................... 178
Classic Load Balancer Metrics ..................................................................................... 179
Metric Dimensions for Classic Load Balancers ............................................................... 182
Amazon EMR ................................................................................................................... 182
Amazon EMR Metrics ................................................................................................ 182
Amazon EMR Dimensions .......................................................................................... 190
Amazon ES ...................................................................................................................... 191
Amazon Elasticsearch Service Metrics .......................................................................... 191
Dimensions for Amazon Elasticsearch Service Metrics .................................................... 193
Elastic Transcoder ............................................................................................................. 194
Elastic Transcoder Metrics .......................................................................................... 194
Dimensions for Elastic Transcoder Metrics .................................................................... 195
AWS IoT .......................................................................................................................... 195
AWS IoT Metrics ...................................................................................................... 195
Dimensions for AWS IoT Metrics ................................................................................. 197
Amazon Kinesis Streams .................................................................................................... 197
Basic Stream-level Metrics .......................................................................................... 197
Enhanced Shard-level Metrics ..................................................................................... 201
Dimensions for Amazon Kinesis Metrics ........................................................................ 203
Amazon Kinesis Firehose ................................................................................................... 203
Service-level CloudWatch Metrics ................................................................................ 203
API-Level CloudWatch Metrics ..................................................................................... 204
AWS KMS ........................................................................................................................ 205
AWS KMS Metrics ..................................................................................................... 205
Dimensions for AWS KMS Metrics ............................................................................... 206
AWS Lambda ................................................................................................................... 206
CloudWatch Metrics ................................................................................................... 206
Dimensions for AWS Lambda Metrics ........................................................................... 207
Amazon Machine Learning .................................................................................................. 207
Amazon ML Metrics ................................................................................................... 208
Dimensions for Amazon Machine Learning Metrics ......................................................... 208
AWS OpsWorks ................................................................................................................ 208
AWS OpsWorks Metrics ............................................................................................. 208
Dimensions for AWS OpsWorks Metrics ........................................................................ 210
Amazon Redshift ............................................................................................................... 210
Amazon Redshift Metrics ............................................................................................ 210
Dimensions for Amazon Redshift Metrics ...................................................................... 212
Amazon RDS .................................................................................................................... 212
Amazon RDS Metrics ................................................................................................. 213
Dimensions for RDS Metrics ....................................................................................... 214
Amazon Route 53 .............................................................................................................. 215
Amazon Route 53 Metrics ........................................................................................... 215
Dimensions for Amazon Route 53 Metrics ..................................................................... 216
Amazon SNS .................................................................................................................... 216
Amazon Simple Notification Service Metrics ................................................................... 216
Dimensions for Amazon Simple Notification Service Metrics ............................................. 217
Amazon SQS .................................................................................................................... 218
Amazon SQS Metrics ................................................................................................. 218
Dimensions for Amazon SQS Metrics ........................................................................... 219
Amazon S3 ...................................................................................................................... 220
Amazon S3 CloudWatch Metrics .................................................................................. 220
Amazon S3 CloudWatch Dimensions ............................................................................ 220
Amazon SWF ................................................................................................................... 220
vii
Amazon CloudWatch User Guide
Workflow Metrics ....................................................................................................... 221
Activity Metrics .......................................................................................................... 221
AWS Storage Gateway ....................................................................................................... 222
AWS Storage Gateway Metrics .................................................................................... 222
Dimensions for AWS Storage Gateway Metrics .............................................................. 233
AWS WAF ........................................................................................................................ 233
AWS WAF Metrics ..................................................................................................... 233
Dimensions for AWS WAF .......................................................................................... 234
Amazon WorkSpaces ......................................................................................................... 234
Amazon WorkSpaces Metrics ...................................................................................... 234
Dimensions for Amazon WorkSpaces Metrics ................................................................ 236
Making API Requests ................................................................................................................. 237
Amazon CloudWatch Endpoints ........................................................................................... 237
Query Parameters ............................................................................................................. 237
The RequestId .................................................................................................................. 238
Query API Authentication .................................................................................................... 238
Query API Examples Using Signature Version 2 .................................................................... 240
Query API Error Messages Using Signature Version 2 ............................................................ 242
Available Libraries ............................................................................................................. 243
Document History ...................................................................................................................... 244
AWS Glossary .......................................................................................................................... 250
viii
Amazon CloudWatch User Guide
Architecture
What is Amazon CloudWatch?
Amazon CloudWatch monitors your Amazon Web Services (AWS) resources and the applications you
run on AWS in real-time. You can use CloudWatch to collect and track metrics, which are the variables
you want to measure for your resources and applications. CloudWatch alarms send notifications or
automatically make changes to the resources you are monitoring based on rules that you define. For
example, you can monitor the CPU usage and disk reads and writes of your Amazon Elastic Compute
Cloud (Amazon EC2) instances and then use this data to determine whether you should launch
additional instances to handle increased load. You can also use this data to stop under-used instances
to save money. In addition to monitoring the built-in metrics that come with AWS, you can monitor
your own custom metrics. With CloudWatch, you gain system-wide visibility into resource utilization,
application performance, and operational health.
The rest of this section introduces the key concepts and terms that will help you understand what you
need to do to monitor your resources and applications.
Topics
Amazon CloudWatch Architecture (p. 1)
Amazon CloudWatch Concepts (p. 2)
Supported AWS Services (p. 9)
Accessing CloudWatch (p. 13)
Regions and Endpoints (p. 13)
CloudWatch Limits (p. 13)
Related AWS Services (p. 14)
Amazon CloudWatch Resources (p. 15)
The Getting Set Up with CloudWatch section walks you through the process of signing up for AWS
and setting up the AWS and CloudWatch command-line interfaces (CLI). The Getting Started with
CloudWatch section walks you through the process of publishing metrics, getting statistics, and setting
alarms.
Amazon CloudWatch Architecture
Amazon CloudWatch is basically a metrics repository. An AWS product—such as Amazon EC2—
puts metrics into the repository, and you retrieve statistics based on those metrics. If you put your own
custom metrics into the repository, you can retrieve statistics on these metrics as well.
1
Amazon CloudWatch User Guide
Concepts
You can use metrics to calculate statistics and then present the data graphically in the CloudWatch
console. For more information about the other AWS resources that generate and send metrics to
CloudWatch, see Amazon CloudWatch Namespaces, Dimensions, and Metrics Reference (p. 140).
You can configure alarm actions to stop, start, or terminate an Amazon EC2 instance when certain
criteria are met. In addition, you can create alarms that initiate Auto Scaling and Amazon Simple
Notification Service (Amazon SNS) actions on your behalf. For more information about creating
CloudWatch alarms, see Alarms (p. 8).
Amazon CloudWatch Concepts
The terminology and concepts that are central to your understanding and use of Amazon CloudWatch
are described below.
Topics
Metrics (p. 3)
Namespaces (p. 3)
Dimensions (p. 4)
Time Stamps (p. 6)
Units (p. 6)
Statistics (p. 7)
Periods (p. 7)
Aggregation (p. 8)
Alarms (p. 8)
Regions (p. 9)
2
Amazon CloudWatch User Guide
Metrics
Metrics
A metric is the fundamental concept in CloudWatch. It represents a time-ordered set of data points that
are published to CloudWatch. These data points can be either your custom metrics or metrics from
other services in AWS. You can retrieve statistics about those data points as an ordered set of time-
series data. Metrics exist only in the region in which they are created. Metrics cannot be deleted, but
they automatically expire in 14 days if no new data is published to them.
Think of a metric as a variable to monitor, and the data points represent the values of that variable over
time. For example, the CPU usage of a particular Amazon EC2 instance is one metric, and the latency
of an Elastic Load Balancing load balancer is another.
The data points themselves can come from any application or business activity from which you collect
data, not just Amazon Web Services products and applications. For example, a metric might be the
CPU usage of a particular Amazon EC2 instance or the temperature in a refrigeration facility.
Metrics are uniquely defined by a name, a namespace, and one or more dimensions. Each data point
has a time stamp, and (optionally) a unit of measure. When you request statistics, the returned data
stream is identified by namespace, metric name, dimension, and (optionally) the unit.
You can use the PutMetricData API action (or the aws cloudwatch put-metric-data
command) to create a custom metric and publish data points for it. You can add the data points in any
order, and at any rate you choose. For more information, see Publish Custom Metrics (p. 73).
CloudWatch stores your metric data for two weeks. You can publish metric data from multiple sources,
such as incoming network traffic from dozens of different Amazon EC2 instances, or requested page
views from several different web applications. You can request statistics on metric data points that
occur within a specified time window.
Related Topics
PutMetricData (put-metric-data)
ListMetrics (list-metrics)
GetMetricStatistics (get-metric-statistics)
View Available Metrics (p. 37)
Namespaces
CloudWatch namespaces are containers for metrics. Metrics in different namespaces are isolated from
each other, so that metrics from different applications are not mistakenly aggregated into the same
statistics.
Namespace names are strings that you define when you create a metric. The names must be valid
XML characters, typically containing the alphanumeric characters "0-9A-Za-z" plus "."(period), "-"
(hyphen), "_" (underscore), "/" (slash), "#" (hash), and ":" (colon). AWS namespaces all follow the
convention AWS/<service>, such as AWS/EC2 and AWS/ELB.
Note
Namespace names must be fewer than 256 characters in length.
There is no default namespace. You must specify a namespace for each data element you put into
CloudWatch.
Related Topics
AWS Namespaces (p. 141)
3
Amazon CloudWatch User Guide
Dimensions
Aggregating Statistics Across Instances (p. 48)
Dimensions
A dimension is a name/value pair that helps you to uniquely identify a metric. Every metric has specific
characteristics that describe it, and you can think of dimensions as categories for those characteristics.
Dimensions help you design a structure for your statistics plan. Because dimensions are part of the
unique identifier for a metric, whenever you add a unique name/value pair to one of your metrics, you
are creating a new metric.
You specify dimensions when you create a metric with the PutMetricData action (or its command
line equivalent put-metric-data). Services in AWS that feed data to CloudWatch also attach
dimensions to each metric. You can use dimensions to filter result sets that CloudWatch queries return.
For example, you can get statistics for a specific Amazon EC2 instance by calling
GetMetricStatistics with the InstanceID dimension set to a specific Amazon EC2 instance ID.
For metrics produced by certain services such as Amazon EC2, CloudWatch can aggregate data
across dimensions. For example, if you call GetMetricStatistics for a metric in the AWS/EC2
namespace and do not specify any dimensions, CloudWatch aggregates all data for the specified
metric to create the statistic that you requested. However, CloudWatch does not aggregate across
dimensions for metrics that you create with PutMetricData or put-metric-data.
Note
You can assign up to ten dimensions to a metric.
In the figure at the end of this section, the four calls to put-metric-data create four distinct metrics.
If you make only those four calls, you could retrieve statistics for these four dimension combinations:
Server=Prod,Domain=Frankfurt
Server=Prod,Domain=Rio
Server=Beta,Domain=Frankfurt
Server=Beta,Domain=Rio
You could not retrieve statistics using combinations of dimensions that you did not specifically create.
For example, you could not retrieve statistics for any of the following combinations of dimensions
unless you create new metrics that specify these combinations with additional calls to put-metric-
data:
Server=Prod,Domain=<null>
Server=<null>,Domain=Frankfurt
Server=Beta,Domain=<null>
Server=<null>,Domain=Rio
Server=Prod
Server=Beta
Important
CloudWatch treats each unique combination of dimensions as a separate metric. For
example, each call to put-metric-data in the following figure creates a separate metric
because each call uses a different set of dimensions. This is true even though all four calls
use the same metric name (ServerStats). For information on how this affects pricing, see
the Amazon CloudWatch product information page.
4
Amazon CloudWatch User Guide
Dimensions
5
Amazon CloudWatch User Guide
Time Stamps
Related Topics
put-metric-data
get-metric-statistics
Dimensions for Amazon EC2 Metrics (p. 172)
Time Stamps
With Amazon CloudWatch, each metric data point must be marked with a time stamp. The time stamp
can be up to two weeks in the past and up to two hours into the future. If you do not provide a time
stamp, CloudWatch creates a time stamp for you based on the time the data element was received.
The time stamp you use in the request must be a dateTime object, with the complete date plus hours,
minutes, and seconds. For more information, see http://www.w3.org/TR/xmlschema-2/#dateTime.
For example: 2013-01-31T23:59:59Z. Although it is not required, we recommend that you provide the
time stamp in the Coordinated Universal Time (UTC or Greenwich Mean Time) time zone. When you
retrieve your statistics from CloudWatch, all times reflect the UTC time zone.
Note
CloudWatch alarms check metrics based on the current time in UTC. Custom metrics sent to
CloudWatch with time stamps other than the current UTC time may cause alarms to display
Insufficient Data state or result in delayed alarms.
Units
Units represent your statistic's unit of measure. For example, the units for the Amazon EC2
NetworkIn metric are Bytes because NetworkIn tracks the number of bytes that an instance
receives on all network interfaces.
You can also specify a unit when you create a custom metric. Units help provide conceptual meaning
to your data. Metric data points that specify a unit of measure, such as Percent, are aggregated
separately. The following list provides some of the more common units that CloudWatch supports:
Seconds
Bytes
Bits
Percent
Count
Bytes/Second (bytes per second)
Bits/Second (bits per second)
Count/Second (counts per second)
None (default when no unit is specified)
For a complete list of the units that CloudWatch supports, see the MetricDatum data type in the
Amazon CloudWatch API Reference.
Though CloudWatch attaches no significance to a unit internally, other applications can derive
semantic information based on the unit you choose. When you publish data without specifying a
unit, CloudWatch associates it with the None unit. When you get statistics without specifying a unit,
CloudWatch aggregates all data points of the same unit together. If you have two otherwise identical
metrics with different units, two separate data streams will be returned, one for each unit.
6
Amazon CloudWatch User Guide
Statistics
Statistics
Statistics are metric data aggregations over specified periods of time. CloudWatch provides statistics
based on the metric data points provided by your custom data or provided by other services in AWS
to CloudWatch. Aggregations are made using the namespace, metric name, dimensions, and the data
point unit of measure, within the time period you specify. The following table describes the available
statistics.
Statistic Description
Minimum The lowest value observed during the specified period. You can use this value to
determine low volumes of activity for your application.
Maximum The highest value observed during the specified period. You can use this value to
determine high volumes of activity for your application.
Sum All values submitted for the matching metric added together. This statistic can be
useful for determining the total volume of a metric.
Average The value of Sum / SampleCount during the specified period. By comparing this
statistic with the Minimum and Maximum, you can determine the full scope of
a metric and how close the average use is to the Minimum and Maximum. This
comparison helps you to know when to increase or decrease your resources as
needed.
SampleCount The count (number) of data points used for the statistical calculation.
You use the GetMetricStatistics API action or the get-metric-statistics command to
retrieve statistics, specifying the same values that you used for the namespace, metric name, and
dimension parameters when the metric values were created. You also specify the start and end times
that CloudWatch will use for the aggregation. The starting and ending points can be as close together
as 60 seconds, and as far apart as two weeks.
Amazon CloudWatch allows you to add pre-calculated statistics using the PutMetricData API action
(or the put-metric-data command) with the StatisticValues (statistic-values) parameter.
Instead of data point values, you specify values for SampleCount, Minimum, Maximum, and Sum
(CloudWatch calculates the average for you). The values you add in this way are aggregated with any
other values associated with the matching metric.
Related Topics
PutMetricData (put-metric-data)
GetMetricStatistics (get-metric-statistics)
Periods
A period is the length of time associated with a specific Amazon CloudWatch statistic. Each statistic
represents an aggregation of the metrics data collected for a specified period of time. Although periods
are expressed in seconds, the minimum granularity for a period is one minute. Accordingly, you specify
period values as multiples of 60. For example, to specify a period of six minutes, you would use the
value 360. You can adjust how the data is aggregated by varying the length of the period. A period can
be as short as one minute (60 seconds) or as long as one day (86,400 seconds).
When you call GetMetricStatistics, you can specify the period length with the Period parameter.
Two related parameters, StartTime and EndTime, determine the overall length of time associated
7
Amazon CloudWatch User Guide
Aggregation
with the statistics. The default value for the Period parameter is 60 seconds, whereas the default
values for StartTime and EndTime give you the last hour's worth of statistics.
The values you select for the StartTime and EndTime parameters determine how many periods
GetMetricStatistics will return. For example, calling GetMetricStatistics with the default
values for the Period, EndTime, and StartTime parameters returns an aggregated set of statistics
for each minute of the previous hour. If you prefer statistics aggregated into ten-minute blocks, set
Period to 600. For statistics aggregated over the entire hour, use a Period value of 3600.
Periods are also an important part of the CloudWatch alarms feature. When you create an alarm
to monitor a specific metric, you are asking CloudWatch to compare that metric to the threshold
value that you supplied. You have extensive control over how CloudWatch makes that comparison.
Not only can you specify the period over which the comparison is made, but you can also specify
how many evaluation periods are used to arrive at a conclusion. For example, if you specify three
evaluation periods, CloudWatch compares a window of three datapoints. CloudWatch only notifies
you if the oldest datapoint is breaching and the others are breaching or missing. For metrics that are
continuously emitted, CloudWatch won't notify you until three failures are found. For more information
about alarms, see Alarms (p. 8).
Aggregation
Amazon CloudWatch aggregates statistics according to the period length that you specify in calls to
GetMetricStatistics. You can publish as many data points as you want with the same or similar
time stamps. CloudWatch aggregates them by period length when you get statistics about those data
points with GetMetricStatistics. Aggregated statistics are only available when using detailed
monitoring. In addition, Amazon CloudWatch does not aggregate data across regions.
You can publish data points for a metric that share not only the same time stamp, but also the same
namespace and dimensions. Subsequent calls to GetMetricStatistics returns aggregated
statistics about those data points. You can even do this in one PutMetricData request. CloudWatch
accepts multiple data points in the same PutMetricData call with the same time stamp. You can
also publish multiple data points for the same or different metrics, with any time stamp. The size of
a PutMetricData request, however, is limited to 8KB for HTTP GET requests and 40KB for HTTP
POST requests. You can include a maximum of 20 data points in one PutMetricData request.
For large data sets that would make the use of PutMetricData impractical, CloudWatch allows for
the insertion of a pre-aggregated data set called a StatisticSet. With StatisticSets you give CloudWatch
the Min, Max, Sum, and SampleCount of a number of data points. StatisticSets is commonly used
when you need to collect data many times in a minute. For example, let’s say you have a metric for the
request latency of a web page. It doesn’t make sense to do a PutMetricData request with every web
page hit. We suggest you collect the latency of all hits to that web page, aggregate them together once
a minute and send that StatisticSet to CloudWatch.
Amazon CloudWatch doesn't differentiate the source of a metric. If you publish a metric with the same
namespace and dimensions from different sources, CloudWatch treats this as a single metric. This can
be useful for service metrics in a distributed, scaled system. For example, all the hosts in a web server
application could publish identical metrics representing the latency of requests they are processing.
CloudWatch treats these as a single metric, allowing you to get the statistics for minimum, maximum,
average, and sum of all requests across your application.
Alarms
Alarms can automatically initiate actions on your behalf, based on parameters you specify. An alarm
watches a single metric over a specified time period, and performs one or more actions based on
the value of the metric relative to a given threshold over a number of time periods. The action is a
notification sent to an Amazon Simple Notification Service (Amazon SNS) topic or Auto Scaling policy.
Alarms invoke actions for sustained state changes only. CloudWatch alarms will not invoke actions
8
Amazon CloudWatch User Guide
Regions
simply because they are in a particular state, the state must have changed and been maintained for a
specified number of periods. Alarm actions must reside in the same region as the alarm. For example,
any Amazon SNS message, Auto Scaling policy, etc. invoked by an alarm must exist in the same
region as the alarm and the resource being monitored.
When creating an alarm, select a period that is greater than or equal to the frequency of the metric
to be monitored. For example, basic monitoring for Amazon EC2 instances provides metrics every 5
minutes. When setting an alarm on a basic monitoring metric, select a period of at least 300 seconds
(5 minutes). Detailed monitoring for Amazon EC2 instances provides metrics every 1 minute; when
setting an alarm on a detailed monitoring metric, select a period of at least 60 seconds (1 minute).
Alarms exist only in the region in which they are created. Alarm history is available for the last 14 days.
Related Topics
PutMetricAlarm
put-metric-alarm
Creating Amazon CloudWatch Alarms (p. 76)
For examples that show you how to set up CloudWatch alarms that invoke an Auto Scaling policy and
an Amazon SNS topic, see Creating Amazon CloudWatch Alarms (p. 76).
Regions
Amazon cloud computing resources are housed in highly available data center facilities. To provide
additional scalability and reliability, each data center facility is located in a specific geographical area,
known as a region. Regions are large and widely dispersed geographic locations.
Each Amazon region is designed to be completely isolated from the other Amazon regions. This
achieves the greatest possible failure isolation and stability, and it makes the locality of each Amazon
resource unambiguous. Amazon CloudWatch does not aggregate data across regions. Therefore,
metrics are completely separate between regions.
For more information about the endpoints that represent each region, see Regions and Endpoints in
the Amazon Web Services General Reference.
Supported AWS Services
CloudWatch monitors the following services. As soon as you begin using a service, it automatically
sends metrics to CloudWatch for you.
CloudWatch offers either basic or detailed monitoring for supported AWS products. Basic monitoring
means that a service sends data points to CloudWatch every five minutes. Detailed monitoring means
that a service sends data points to CloudWatch every minute.
Note
If you are using a service that supports both basic and detailed data collection (for example,
Amazon EC2 and Auto Scaling), and you want to access detailed statistics, you must enable
detailed metric collection for that service.
Amazon API Gateway
Amazon API Gateway sends data to CloudWatch every 5 minutes by default. You can create alarms
using Amazon API Gateway Dimensions and Metrics (p. 142). For more information, see Monitor
API execution with Amazon CloudWatch in the API Gateway Developer Guide.
9
Amazon CloudWatch User Guide
Supported AWS Services
Auto Scaling
Auto Scaling sends data to CloudWatch every 5 minutes by default. For an additional charge, you
can enable detailed monitoring for Auto Scaling, which sends data to CloudWatch every minute. You
can create alarms using Auto Scaling Dimensions and Metrics (p. 144). For more information, see
Monitor Your Auto Scaling Instances in the Auto Scaling User Guide.
Amazon CloudFront
Amazon CloudFront sends data to CloudWatch every minute by default. You can create alarms
using Amazon CloudFront Dimensions and Metrics (p. 145). For more information, see Monitoring
CloudFront Activity Using CloudWatch in the Amazon CloudFront Developer Guide.
Amazon CloudSearch
Amazon CloudSearch sends data to CloudWatch every minute by default. You can create alarms
using Amazon CloudSearch Dimensions and Metrics (p. 146). For more information, see
Monitoring an Amazon CloudSearch Domain with Amazon CloudWatch in the Amazon CloudSearch
Developer Guide.
Amazon CloudWatch Events
Amazon CloudWatch Events sends data to CloudWatch every minute by default. You can create
alarms using Amazon CloudWatch Events Dimensions and Metrics (p. 147).
Amazon CloudWatch Logs
Amazon CloudWatch Logs sends data to CloudWatch every minute by default. You can create
alarms using Amazon CloudWatch Logs Dimensions and Metrics (p. 148).
Amazon DynamoDB
Amazon DynamoDB sends data to CloudWatch every minute for some metrics and every 5 minutes
for other metrics. For more information about these metrics, see Amazon DynamoDB Dimensions
and Metrics (p. 150). For more information about how to monitor DynamoDB, see Monitoring
DynamoDB Tables with Amazon CloudWatch in the Amazon DynamoDB Developer Guide.
Amazon EC2 Container Service
Amazon EC2 Container Service (Amazon ECS) sends data to CloudWatch every minute. You can
create alarms using Amazon ECS Dimensions and Metrics (p. 160). For more information, see
Amazon ECS CloudWatch Metrics in the Amazon EC2 Container Service Developer Guide.
Amazon ElastiCache
Amazon ElastiCache sends data to CloudWatch every minute. You can create alarms using Amazon
ElastiCache Dimensions and Metrics (p. 162). For more information, see Viewing Cache Cluster
and Cache Node Metrics in the Amazon ElastiCache User Guide.
Amazon Elastic Block Store
Amazon Elastic Block Store sends data to CloudWatch every 5 minutes. You can create alarms
using Amazon EBS Dimensions and Metrics (p. 167). For more information, see Monitoring the
Status of Your Volumes in the Amazon EC2 User Guide for Linux Instances.
Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) sends data to CloudWatch every 5 minutes by
default. For an additional charge, you can enable detailed monitoring for Amazon EC2, which sends
data to CloudWatch every minute.
Amazon EC2 provides CloudWatch metrics for your instances. You can create alarms using
Amazon Elastic Compute Cloud Dimensions and Metrics (p. 169). For more information, see
Monitoring Your Instances in the Amazon EC2 User Guide for Linux Instances.
Amazon EC2 provides CloudWatch metrics for the Spot instances in your fleet. You can use
Amazon EC2 Spot Fleet Dimensions and Metrics (p. 173) to monitor your Spot fleet. For more
10
Amazon CloudWatch User Guide
Supported AWS Services
information, see CloudWatch Metrics for Spot Fleet in the Amazon EC2 User Guide for Linux
Instances
Amazon Elastic File System
Amazon Elastic File System sends data to CloudWatch every minute. You can create alarms using
Amazon EFS Dimensions and Metrics (p. 174). For more information, see Monitor Metrics with
CloudWatch in the Amazon Elastic File System User Guide.
Elastic Load Balancing
Elastic Load Balancing sends data to CloudWatch every minute. You can create alarms using Elastic
Load Balancing Dimensions and Metrics (p. 177). For more information, see Monitor Your Load
Balancer Using Amazon CloudWatch in the Elastic Load Balancing User Guide.
Amazon EMR
Amazon EMR sends data to CloudWatch every 5 minutes. You can create alarms using Amazon
EMR Dimensions and Metrics (p. 182). For more information, see Monitor Metrics with Amazon
CloudWatch in the Amazon EMR Developer Guide.
Amazon Elasticsearch Service
Amazon Elasticsearch Service sends data to CloudWatch every minute. You can create alarms
using Amazon Elasticsearch Service Dimensions and Metrics (p. 191). For more information, see
Monitoring Cluster Metrics and Statistics with Amazon CloudWatch in the Amazon Elasticsearch
Service Developer Guide.
Amazon Elastic Transcoder
Amazon Elastic Transcoder sends data to CloudWatch every minute. You can create alarms
using Amazon Elastic Transcoder Dimensions and Metrics (p. 194). For more information, see
Monitoring Elastic Transcoder in the Amazon Elastic Transcoder Developer Guide.
AWS IoT
AWS IoT sends data to CloudWatch every minute. You can create alarms using AWS IoT
Dimensions and Metrics (p. 195). For more information, see Monitoring with Amazon CloudWatch
in the AWS IoT Developer Guide.
Amazon Kinesis Streams
Amazon Kinesis Streams sends data to CloudWatch every minute. You can create alarms using
Amazon Kinesis Streams Dimensions and Metrics (p. 197). For more information, see Monitoring
Amazon Kinesis with Amazon CloudWatch in the Amazon Kinesis Developer Guide.
Amazon Kinesis Firehose
Amazon Kinesis Firehose sends data to CloudWatch every minute. You can create alarms using
Amazon Kinesis Firehose Metrics (p. 203). For more information, see Monitoring Amazon Kinesis
Firehose with Amazon CloudWatch in the Amazon Kinesis Firehose Developer Guide.
AWS Key Management Service
AWS Key Management Service sends data to CloudWatch every minute. You can create alarms
using AWS Key Management Service Metrics and Dimensions (p. 205). For more information, see
Monitoring with Amazon CloudWatch in the AWS Key Management Service Developer Guide.
AWS Lambda
AWS Lambda sends data to CloudWatch every minute. You can create alarms using AWS Lambda
Dimensions and Metrics (p. 206). For more information, see Troubleshooting and Monitoring AWS
Lambda Functions with Amazon CloudWatch in the AWS Lambda Developer Guide.
Amazon Machine Learning
Amazon Machine Learning sends data to CloudWatch every 5 minutes. You can create alarms using
Amazon Machine Learning Dimensions and Metrics (p. 207). For more information, see Monitoring
11
Amazon CloudWatch User Guide
Supported AWS Services
Amazon Machine Learning with Amazon CloudWatch Metrics in the Amazon Machine Learning
Developer Guide.
AWS OpsWorks
AWS OpsWorks sends data to CloudWatch every minute. You can create alarms using AWS
OpsWorks Dimensions and Metrics (p. 208). For more information, see Monitoring in the AWS
OpsWorks User Guide.
Amazon Redshift
Amazon Redshift sends data to CloudWatch every minute. You can create alarms using Amazon
Redshift Dimensions and Metrics (p. 210). For more information, see Monitoring Amazon Redshift
Cluster Performance in the Amazon Redshift Cluster Management Guide.
Amazon Relational Database Service
Amazon Relational Database Service sends data to CloudWatch every minute. You can create
alarms using Amazon RDS Dimensions and Metrics (p. 212). For more information, see Monitoring
a DB Instance in the Amazon Relational Database Service User Guide.
Amazon Route 53
Amazon Route 53 sends data to CloudWatch every minute. You can create alarms using Amazon
Route 53 Dimensions and Metrics (p. 215). For more information, see Monitoring Health Checks
Using Amazon CloudWatch in the Amazon Route 53 Developer Guide.
Amazon Simple Notification Service
Amazon Simple Notification Service sends data to CloudWatch every 5 minutes. You can create
alarms using Amazon Simple Notification Service Dimensions and Metrics (p. 216). For more
information, see Monitoring Amazon SNS with Amazon CloudWatch in the Amazon Simple
Notification Service Developer Guide.
Amazon Simple Queue Service
Amazon Simple Queue Service sends data to CloudWatch every 5 minutes. You can create alarms
using Amazon SQS Dimensions and Metrics (p. 218). For more information, see Monitoring
Amazon SQS with Amazon CloudWatch in the Amazon Simple Queue Service Developer Guide.
Amazon Simple Storage Service
Amazon Simple Storage Service sends data to CloudWatch once a day. You can create alarms
using Amazon Simple Storage Service Dimensions and Metrics (p. 220). For more information,
see Monitoring Amazon Simple Storage Service with Amazon CloudWatch in the Amazon Simple
Storage Service Developer Guide.
Amazon Simple Workflow Service
Amazon Simple Workflow Service sends data to CloudWatch every 5 minutes. You can create
alarms using Amazon SWF Dimensions and Metrics (p. 220). For more information, see Viewing
Amazon SWF Metrics for CloudWatch using the AWS Management Console in the Amazon Simple
Workflow Service Developer Guide.
AWS Storage Gateway
AWS Storage Gateway sends data to CloudWatch every 5 minutes. You can create alarms using
AWS Storage Gateway Dimensions and Metrics (p. 222). For more information, see Monitoring
Your AWS Storage Gateway in the AWS Storage Gateway User Guide.
AWS WAF
AWS WAF sends data to CloudWatch every minute. You can create alarms using AWS WAF
Dimensions and Metrics (p. 233). For more information, see Testing Web ACLs in the AWS WAF
Developer Guide.
Amazon WorkSpaces
12
Amazon CloudWatch User Guide
Accessing CloudWatch
Amazon WorkSpaces sends data to CloudWatch every 5 minutes. You can create alarms using
Amazon WorkSpaces Dimensions and Metrics (p. 234). For more information about how to
monitor Amazon WorkSpaces, see Monitoring Amazon WorkSpaces in the Amazon WorkSpaces
Administration Guide.
Accessing CloudWatch
You can access CloudWatch using any of the following:
Amazon CloudWatch console
For more information about the CloudWatch console, see Sign in to the Amazon CloudWatch
Console (p. 17).
AWS Console for Android and iOS
For more information about the AWS Console, see AWS Console for Android and iOS.
CloudWatch CLI
For information about how to install and configure the Amazon CloudWatch CLI, see Set Up the
Command Line Interface in the Amazon CloudWatch CLI Reference.
AWS CLI
For information about how to install and configure the AWS CLI, see Getting Set Up with the AWS
Command Line Interface in the AWS Command Line Interface User Guide.
CloudWatch API
For more information about the CloudWatch API, see Amazon CloudWatch API Reference.
AWS SDKs
For more information about the AWS SDKs, see Tools for Amazon Web Services.
Regions and Endpoints
You monitor metrics and create alarms in a specific AWS region. You send your CloudWatch requests
to a region-specific endpoint. For a list of supported AWS regions, see Regions and Endpoints in the
Amazon Web Services General Reference.
CloudWatch Limits
CloudWatch has the following limits:
Resource Default Limit
Actions 5/alarm. This limit cannot be changed.
Alarms 10/month/customer for free. 5000/account.
API requests 1,000,000/month/customer for free.
Custom metrics No limit.
13
Amazon CloudWatch User Guide
Related AWS Services
Resource Default Limit
DescribeAlarms 3 transactions per second (TPS). The maximum number of
operation requests you can make per second without being
throttled.
You can request a limit increase.
Dimensions 10/metric. This limit cannot be changed.
GetMetricStatistics 400 transactions per second (TPS). The maximum number
of operation requests you can make per second without
being throttled.
You can request a limit increase.
ListMetrics 25 transactions per second (TPS). The maximum number
of operation requests you can make per second without
being throttled.
You can request a limit increase.
Metric data 2 weeks. This limit cannot be changed.
MetricDatum items 20/PutMetricData request. A MetricDatum object can
contain a single value or a StatisticSet object representing
many values. This limit cannot be changed.
Metrics 10/month/customer for free.
Period One day (86,400 seconds). This limit cannot be changed.
PutMetricAlarm request 3 transactions per second (TPS). The maximum number of
operation requests you can make per second without being
throttled.
You can request a limit increase.
PutMetricData request 8 KB for HTTP GET requests and 40 KB for HTTP POST
requests. PutMetricData can handle 150 transactions per
second (TPS), which is the maximum number of operation
requests you can make per second without being throttled.
You can request a limit increase.
Amazon SNS email notifications 1,000/month/customer for free.
Related AWS Services
The following services are used in conjunction with Amazon CloudWatch:
Auto Scaling is a web service that enables you to automatically launch or terminate Amazon
Elastic Compute Cloud (Amazon EC2) instances based on user-defined policies, health status
checks, and schedules. You can use a CloudWatch alarm with Auto Scaling to scale Amazon EC2
instances based on demand. For more information, see Scale Based on Demand in the Auto Scaling
Developer Guide.
Amazon Simple Notification Service (Amazon SNS) is a web service that coordinates and
manages the delivery or sending of messages to subscribing endpoints or clients. You use Amazon
14
Amazon CloudWatch User Guide
Resources
SNS with CloudWatch to send messages when an alarm threshold has been reached. For more
information, see Set Up Amazon Simple Notification Service (p. 78).
AWS CloudTrail is a web service that enables you to monitor the calls made to the Amazon
CloudWatch API for your account, including calls made by the AWS Management Console,
command line interface (CLI), and other services. When CloudTrail logging is turned on, CloudWatch
will write log files into the Amazon S3 bucket that you specified when you configured CloudTrail.
Each log file can contain one or more records, depending on how many actions must be performed
to satisfy a request. For more information about AWS CloudTrail, see What is AWS CloudTrail? in
the AWS CloudTrail User Guide. For an example of the type of data that CloudWatch writes into
CloudTrail log files, see Logging Amazon CloudWatch API Calls in AWS CloudTrail (p. 110).
AWS Identity and Access Management (IAM) is a web service that helps you securely control
access to AWS resources for your users. Use IAM to control who can use your AWS resources
(authentication) and what resources they can use in which ways (authorization). For more
information, see What is IAM? in the IAM User Guide.
Amazon Kinesis Streams is a web service you can use for rapid and continuous data intake and
aggregation. The type of data used includes IT infrastructure log data, application logs, social media,
market data feeds, and web clickstream data. Because the response time for the data intake and
processing is in real time, processing is typically lightweight. For more information, see What is
Amazon Kinesis Streams? in the Amazon Kinesis Streams Developer Guide.
AWS Lambda is a web service you can use to build applications that respond quickly to new
information. Upload your application code as Lambda functions and Lambda runs your code on high-
availability compute infrastructure and performs all the administration of the compute resources,
including server and operating system maintenance, capacity provisioning and automatic scaling,
code and security patch deployment, and code monitoring and logging. All you need to do is supply
your code in one of the languages that Lambda supports. For more information, see What is AWS
Lambda? in the AWS Lambda Developer Guide.
Amazon CloudWatch Resources
The following table lists related resources that you'll find useful as you work with Amazon CloudWatch.
Resource Description
Amazon CloudWatch FAQs The FAQ covers the top questions developers have asked
about this product.
Release notes The release notes give a high-level overview of the
current release. They specifically note any new features,
corrections, and known issues.
AWS Developer Resource Center A central starting point to find documentation, code
samples, release notes, and other information to help you
build innovative applications with AWS.
AWS Management Console The console allows you to perform most of the functions
of Amazon CloudWatch and various other AWS products
without programming.
Amazon CloudWatch Discussion
Forums Community-based forum for developers to discuss
technical questions related to Amazon CloudWatch.
AWS Support The hub for creating and managing your AWS Support
cases. Also includes links to other helpful resources, such
as forums, technical FAQs, service health status, and AWS
Trusted Advisor.
15
Amazon CloudWatch User Guide
Resources
Resource Description
Amazon CloudWatch product
information The primary web page for information about Amazon
CloudWatch.
Contact Us A central contact point for inquiries concerning AWS billing,
account, events, abuse, etc.
16
Amazon CloudWatch User Guide
Sign Up for Amazon Web Services (AWS)
Getting Set Up
To use Amazon CloudWatch you need an AWS account. Your AWS account allows you to use
services (e.g., Amazon EC2) to generate metrics that you can view in the CloudWatch console, a point-
and-click web-based interface. In addition, you need to install and configure the AWS command line
interface (CLI).
Topics
Sign Up for Amazon Web Services (AWS) (p. 17)
Sign in to the Amazon CloudWatch Console (p. 17)
Set Up the Command Line Interface (p. 19)
Sign Up for Amazon Web Services (AWS)
When you create an AWS account, we automatically sign up your account for all AWS services. You
pay only for the services that you use.
If you have an AWS account already, skip to the next step. If you don't have an AWS account, use the
following procedure to create one.
To sign up for an AWS account
1. Open http://aws.amazon.com/, and then choose Create an AWS Account.
2. Follow the online instructions.
Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone
keypad.
Sign in to the Amazon CloudWatch Console
To sign in to the Amazon CloudWatch console
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
The monitoring dashboard opens. Your dashboard might look something like the following:
17
Amazon CloudWatch User Guide
Sign in to the Amazon CloudWatch Console
If you do not have any alarms, the Your Alarms section will have a Create Alarm button. Even if
this is the first time you are using the CloudWatch console, the Your Metrics section could already
report that you are using a significant number of metrics, because several AWS products push free
metrics to Amazon CloudWatch automatically.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
18
Amazon CloudWatch User Guide
Set Up the Command Line Interface
Set Up the Command Line Interface
You can use the Amazon CloudWatch command line interface (CLI) or the AWS CLI with CloudWatch.
The AWS CLI, which is a unified tool for managing multiple AWS services, replaces the CloudWatch
CLI. New CloudWatch features are included only in the AWS CLI. Before you can use either CLI,
however, you have to install and configure them.
For information about how to install and configure the AWS CLI, see Getting Set Up with the AWS
Command Line Interface in the AWS Command Line Interface User Guide.
For information about how to install and configure the Amazon CloudWatch CLI, see Set Up the
Command Line Interface in the Amazon CloudWatch CLI Reference.
19
Amazon CloudWatch User Guide
Scenario: Monitor Your Estimated
Charges Using CloudWatch
Getting Started with Amazon
CloudWatch
The following scenarios show you how to use Amazon CloudWatch. In the first scenario, you use the
CloudWatch console to create a billing alarm that tracks your AWS usage and lets you know when
you have exceeded a certain spending threshold. In the second, more advanced scenario, you use
the AWS command line interface (CLI) to publish a single metric for a hypothetical application named
GetStarted.
Scenario: Monitor Your Estimated Charges Using CloudWatch (p. 20)
Scenario: Publish Metrics to CloudWatch (p. 26)
Scenario: Monitor Your Estimated Charges
Using CloudWatch
In this scenario, you create an Amazon CloudWatch alarm that will monitor your estimated Amazon
Web Services (AWS) charges. When you enable the monitoring of estimated charges for your AWS
account, the estimated charges are calculated and sent several times daily to CloudWatch as metric
data that is stored for 14 days. Billing metric data is stored in the US East (N. Virginia) Region and
represents worldwide charges. This data includes the estimated charges for every service in AWS
that you use, as well as the estimated overall total of your AWS charges. You can choose to receive
alerts by email when charges have exceeded a certain threshold. These alerts are triggered by
CloudWatch and messages are sent using Amazon Simple Notification Service (Amazon SNS). For
more information about working with CloudWatch metrics, see Viewing, Graphing, and Publishing
Metrics (p. 37).
Topics
Step 1: Enable Monitoring of Your Estimated Charges (p. 21)
Step 2: Create a Billing Alarm (p. 21)
Step 3: Check Alarm Status (p. 25)
Step 4: Edit a Billing Alarm (p. 26)
20
Amazon CloudWatch User Guide
Step 1: Enable Monitoring of Your Estimated Charges
Step 5: Delete a Billing Alarm (p. 26)
Step 1: Enable Monitoring of Your Estimated
Charges
Before you can create an alarm on your estimated charges, you must enable monitoring of your
estimated AWS charges, which creates metric data that you can use to create a billing alarm. It takes
about 15 minutes before you can view billing data and create alarms. After you enable billing metrics
you cannot disable the collection of data, but you can delete any alarms you have created. You must
be signed in as the account owner (the "root user") to enable billing alerts for your AWS account.
To enable monitoring of your estimated charges
1. Open the Billing and Cost Management console at https://console.aws.amazon.com/billing/home?
#.
2. In the spaces provided, enter your user name and password, and then click Sign in using our
secure server.
3. In the navigation pane, click Preferences, and then select the Receive Billing Alerts check box.
Step 2: Create a Billing Alarm
After you've enabled monitoring of your estimated AWS charges, you can create a billing alarm in
the Amazon CloudWatch console. In this scenario, you'll create an alarm that will send an email
message when your estimated charges for AWS exceed $200. When you enable the monitoring of
your estimated charges for the first time, it takes about 15 minutes before you can view billing data and
set billing alarms.
To create a billing alarm
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region to US East (N. Virginia). Billing metric data is stored in the US
East (N. Virginia) Region and represent worldwide charges. For more information, see Regions
and Endpoints.
21
Amazon CloudWatch User Guide
Step 2: Create a Billing Alarm
3. In the navigation pane, click Alarms, and then in the Alarms pane, click Create Alarm.
4. In the CloudWatch Metrics by Category pane, under Billing Metrics, click Total Estimated
Charge.
5. Under Billing > Total Estimated Charge, select the EstimatedCharges metric to view a graph of
billing data in the lower pane.
22
Amazon CloudWatch User Guide
Step 2: Create a Billing Alarm
6. Click Next, and then in the Alarm Threshold pane, in the Name box, type a unique, friendly name
for the alarm (for example, My Estimated Charges).
23
Amazon CloudWatch User Guide
Step 2: Create a Billing Alarm
7. In the Description box, enter a description for the alarm (for example, Estimated Monthly
Charges).
8. Under Whenever charges for, in the is drop-down list, select >= (greater than or equal to), and
then in the USD box, set the monetary amount (for example, 200) that must be exceeded to trigger
the alarm and send an email.
Note
Under Alarm Preview, in the Estimated Monthly Charges thumbnail graph, you can
see an estimate of your charges that you can use to set an appropriate threshold for the
alarm.
9. Under Actions, click Notification, and then in the Whenever this alarm drop-down menu, click
State is ALARM.
10. In the Send notification to box, select an existing Amazon SNS topic.
To create a new Amazon SNS topic, click Create topic, and then in the Send notification to box,
enter a name for the new Amazon SNS topic (for example., CFO), and in the Email list box, enter
the email address (for example, john.stiles@example.com) where email notifications should be
sent.
Note
If you create a new Amazon SNS topic, the email account associated with the topic will
receive a subscription confirmation email. You must confirm the subscription in order to
receive future email notifications when the alarm is triggered.
24
Amazon CloudWatch User Guide
Step 3: Check Alarm Status
11. Click Create Alarm.
Important
If you added an email address to the list of recipients or created a new topic, Amazon
SNS sends a subscription confirmation email to each new address shortly after you
create an alarm. Remember to click the link contained in that message, which confirms
your subscription. Alert notifications are only sent to confirmed addresses.
12. To view your billing alarm in the CloudWatch console, in the navigation pane, under Alarms, click
Billing.
Step 3: Check Alarm Status
Now, check the status of the billing alarm that you just created.
To check alarm status using the CloudWatch console
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region to US East (N. Virginia). Billing metric data is stored in the US
East (N. Virginia) Region and represent worldwide charges. For more information, see Regions
and Endpoints.
3. In the navigation pane, under Alarms, click Billing.
25
Amazon CloudWatch User Guide
Step 4: Edit a Billing Alarm
Step 4: Edit a Billing Alarm
Let's say that you want to increase the amount money you spend with AWS each month to $400. You
can edit your existing billing alarm and increase the dollar amount that must be exceeded before the
alarm is triggered.
To edit a billing alarm using the CloudWatch console
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region to US East (N. Virginia). Billing metric data is stored in the US
East (N. Virginia) Region and represent worldwide charges. For more information, see Regions
and Endpoints.
3. In the navigation pane, under Alarms, click Billing.
4. In the list of alarms, select the check box next to the alarm you want to change, and then click
Modify.
5. Under Alarm Threshold, in the USD box, set the monetary amount (for example, 400) that must
be exceeded to trigger the alarm and send an email, and then click Save Changes.
Step 5: Delete a Billing Alarm
Now that you have enabled billing, and you have created and edited your first billing alarm, you can
delete the billing alarm if you no longer need it.
To delete a billing alarm using the CloudWatch console
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region to US East (N. Virginia). Billing metric data is stored in the US
East (N. Virginia) Region and represent worldwide charges. For more information, see Regions
and Endpoints.
3. In the navigation pane, under Alarms, click Billing.
4. In the list of alarms, select the check box next to the alarm you want to delete, and then click
Delete.
5. In the Delete Alarms dialog box, click Yes, Delete.
Scenario: Publish Metrics to CloudWatch
After you have installed the AWS CLI, you're ready to publish metrics to CloudWatch. In this
scenario, you'll use the put-metric-data command in the AWS CLI to publish a single metric for a
hypothetical application named GetStarted. Then, you'll use the CloudWatch console to view statistical
graphs for this metric. For information about how to install and configure the AWS CLI, see Getting
Set Up with the AWS Command Line Interface in the AWS Command Line Interface User Guide. For
more information about working with CloudWatch metrics, see Viewing, Graphing, and Publishing
Metrics (p. 37).
For more information about the put-metric-data command, see put-metric-data in the AWS
Command Line Interface Reference.
Topics
Step 1: Define the Data Configuration (p. 27)
26
Amazon CloudWatch User Guide
Step 1: Define the Data Configuration
Step 2: Add Metrics to CloudWatch (p. 27)
Step 3: Get Statistics from CloudWatch (p. 28)
Step 4: View Graphs with the Console (p. 29)
Step 1: Define the Data Configuration
In this scenario, you'll publish data points that track the request latency for the application. Choose
names for your metric and namespace that make sense to you. For this example, name the metric
RequestLatency and place all of the data points into the GetStarted namespace.
You'll publish several data points that collectively represent three hours of latency data. The raw
data comprises fifteen request latency readings distributed over three hours. Each reading is in
milliseconds:
Hour one: 87, 51, 125, 235
Hour two: 121, 113, 189, 65, 89
Hour three: 100, 47, 133, 98, 100, 328
You can publish data to CloudWatch as single data points or as an aggregated set of data points called
a statistic set. You'll publish the data points from hour one as single data points.
Hour Raw Data
1 87
1 51
1 125
1 235
For the data from hours two and three, you'll aggregate the data points and publish a statistic set for
each hour.
Note
You can aggregate metrics to a granularity as low as one minute.
You can publish the aggregated data points to CloudWatch as a set of statistics with four predefined
keys: Sum, Minimum, Maximum, and SampleCount. The key values are shown in the following table.
Hour Raw Data Sum Minimum Maximum SampleCount
2 121, 113, 189, 65, 89 577 65 189 5
3 100, 47, 133, 98, 100, 328 806 47 328 6
Step 2: Add Metrics to CloudWatch
After you have defined your data configuration, you are ready to begin adding data.
Note
When you use the put-metric-data command, you must use a date range within the past
two weeks. There is currently no function to delete data points. CloudWatch automatically
deletes data points with a timestamp more than two weeks old.
27
Amazon CloudWatch User Guide
Step 3: Get Statistics from CloudWatch
To publish data points to CloudWatch
1. Open a command prompt and enter the following commands, but replace the time stamp with a
time stamp that represents two hours in the past in Universal Coordinated Time (UTC).
aws cloudwatch put-metric-data --metric-name RequestLatency --namespace
GetStarted --timestamp 2014-02-14T20:30:00Z --value 87 --unit
Milliseconds
aws cloudwatch put-metric-data --metric-name RequestLatency --namespace
GetStarted --timestamp 2014-02-14T20:30:00Z --value 51 --unit
Milliseconds
aws cloudwatch put-metric-data --metric-name RequestLatency --namespace
GetStarted --timestamp 2014-02-14T20:30:00Z --value 125 --unit
Milliseconds
aws cloudwatch put-metric-data --metric-name RequestLatency --namespace
GetStarted --timestamp 2014-02-14T20:30:00Z --value 235 --unit
Milliseconds
The AWS CLI returns a response only when it cannot execute the command.
2. Enter the second data point, but this time use a time stamp one hour later than the first one in
Universal Coordinated Time (UTC).
aws cloudwatch put-metric-data --metric-name RequestLatency --namespace
GetStarted --timestamp 2014-02-14T21:30:00Z --statistic-values
Sum=577,Minimum=65,Maximum=189,SampleCount=5 --unit Milliseconds
3. Enter the last data point, but this time omit the time stamp to get the current time (the default
value).
aws cloudwatch put-metric-data --metric-name
RequestLatency --namespace GetStarted --statistic-values
Sum=806,Minimum=47,Maximum=328,SampleCount=6 --unit Milliseconds
After adding metrics, you can get statistics.
Step 3: Get Statistics from CloudWatch
Now that you have published metrics to CloudWatch, you are ready to retrieve statistics that are based
on those metrics.
To retrieve statistics with the command line tools
Specify a --start-time and --end-time far enough in the past to cover the earliest time stamp
that you published.
aws cloudwatch get-metric-statistics --namespace GetStarted --metric-name
RequestLatency --statistics Average --start-time 2014-02-14T00:00:00Z --
end-time 2014-02-15T00:00:00Z --period 60
The AWS CLI returns the following JSON:
{
"Datapoints": [],
"Label": "Request:Latency"
28
Amazon CloudWatch User Guide
Step 4: View Graphs with the Console
}
To see your statistics in a visual format, you can use the CloudWatch console to view graphs.
Step 4: View Graphs with the Console
After you have published metrics to CloudWatch, you can use the CloudWatch console to view
statistical graphs.
To view graphs of your statistics on the console
1. Sign in to the AWS Management Console and open the CloudWatch console at https://
console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the Navigation pane, click Metrics. CloudWatch Metrics by Category opens in the right pane.
4. In the CloudWatch Metrics by Category pane, in the search box, type RequestLatency.
5. Select the check box next to the RequestLatency metric name. A graph of the metric's data is
displayed in the lower pane.
6. To change the graph, choose different values from the Statistic and Period lists located next to
graph's title.
7. To create an alarm for this metric, under Tools, click Create Alarm.
Congratulations! You've successfully published and viewed custom metrics.
29
Amazon CloudWatch User Guide
Create a Dashboard
Using Amazon CloudWatch
Dashboards
Amazon CloudWatch dashboards are customizable home pages in the CloudWatch console that you
can use to monitor your resources in a single view, even those resources that are spread out across
different regions. You can use CloudWatch dashboards to create customized views of the metrics for
your AWS resources.
With dashboards, you can create the following:
A single view for selected metrics to help you assess the health of your resources and applications
across one or more regions.
An operational playbook that provides guidance for team members during operational events about
how to respond to specific incidents.
A common view of critical resource and application measurements that can be shared by team
members for faster communication flow during operational events.
Topics
Create a Dashboard (p. 30)
Add or Remove a Graph from a Dashboard (p. 31)
Move or Resize a Graph on a Dashboard (p. 32)
Edit a Graph on a Dashboard (p. 32)
Rename a Graph on a Dashboard (p. 33)
Add, Edit, or Remove a Text Widget from a Dashboard (p. 33)
Create a Cross-Region Dashboard (p. 34)
Switch Between Dashboards (p. 34)
Link and Unlink Graphs on a Dashboard (p. 34)
Change the Dashboard Refresh Interval (p. 35)
Change the Dashboard Time Range, Period, or Time Format (p. 35)
Create a Dashboard
To get started with CloudWatch dashboards, you must first create a dashboard. You can also create
multiple dashboards to track metrics for your AWS resources.
30
Amazon CloudWatch User Guide
Add or Remove a Graph from a Dashboard
To create a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change to the region where your resources are located. From the navigation bar,
select the region that meets your needs. For more information, see Regions and Endpoints in the
Amazon Web Services General Reference.
3. In the navigation pane, choose Dashboards.
4. In the content pane, choose Create dashboard.
5. In the Create new dashboard dialog box, type a name for the dashboard and then choose Create
dashboard.
6. Do one of the following:
a. To add a graph to your dashboard, in the Add widget to dashboard dialog box, choose
Metric Graph, choose Configure, and then, in the Add Graph dialog box, select the metrics
to graph, and then choose Save.
b. To add a text block to your dashboard, in the Add widget to dashboard dialog box, choose
Text Widget, choose Configure, and then, in the New text widget dialog box, in the
Markdown field, add and format your text using Markdown, and then choose Create widget.
7. Choose Save dashboard.
Add or Remove a Graph from a Dashboard
You can add graphs containing one or more metrics to your dashboard for the resources you monitor.
You can remove the graphs when they're no longer needed.
To add a graph to a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change to the region where your resources are located. From the navigation bar,
select the region that meets your needs. For more information, see Regions and Endpoints in the
Amazon Web Services General Reference.
3. In the navigation pane, choose Dashboards.
4. In the contents pane, choose Add widget.
5. In the Add widget to dashboard dialog box, choose Metric graph to add a graph of a metric over
time to your dashboard.
6. Choose Configure, and then in the Add Graph dialog box, select the metric to graph and choose
Save.
7. (Optional) To temporarily make the graph larger, select the graph.
8. (Optional) To view more information about the metric being graphed, hover over the legend.
9. Choose Save dashboard.
To add a graph from an alarm to a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change to the region where your resources are located. From the navigation bar,
select the region that meets your needs. For more information, see Regions and Endpoints in the
Amazon Web Services General Reference.
3. In the navigation pane, choose Alarms, and then in the contents pane, choose an alarm.
4. In the details pane, click the graph, and then choose Add to Dashboard.
5. In the Add to dashboard dialog box, in the Add to drop-down list, choose the dashboard you
want to add the graph to, and then choose Add to dashboard.
31
Amazon CloudWatch User Guide
Move or Resize a Graph on a Dashboard
6. Choose Save dashboard.
To remove a graph from a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the contents pane, hover over the graph's title, choose Widget actions and then Delete.
4. Choose Save dashboard.
Move or Resize a Graph on a Dashboard
You can arrange and resize graphs on your dashboard.
To move or resize a graph on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. Do one of the following to move, resize, or temporarily make the graph larger:
a. To move the graph, hover over the title of the graph, and then select and drag the graph to a
new location on the dashboard.
b. To resize the graph, select and drag the lower right corner.
c. To temporarily make the graph larger, click the graph. Alternatively, you can hover over the
title of the graph, choose Widget actions and then choose Enlarge.
5. Choose Save dashboard.
Edit a Graph on a Dashboard
You can edit a graph to change the title, statistic, or period, or to add or remove metrics. If you have
multiple metrics displayed on a graph, you can reduce clutter by temporarily hiding the metrics that
don't interest you.
To edit a graph on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. Hover over the title of the graph for which to make changes, choose Widget actions, and choose
Edit.
5. In the lower half of the Edit Graph screen, you can change the title, statistic, or period:
a. To change the graph's title, select the title, enter a new title in the field, and then choose
Save.
b. To change the statistic, which is next to the graph's title, choose the Statistic list, and then
choose another value.
c. To change the time period, which is next to the Statistic list, choose the Period list, and then
choose another value.
6. When you're satisfied with your changes, choose Save.
32
Amazon CloudWatch User Guide
Rename a Graph on a Dashboard
To temporarily hide metrics on a graph on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. In the graph's footer, hover over the colored square in the legend, and then when it changes to an
X, click it.
5. To restore the metric, click the grayed out square and metric name.
Rename a Graph on a Dashboard
You can change the default name that AWS assigns to a graph on your dashboard.
To rename a graph on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. Hover over the title of the graph for which to make changes, choose Widget actions and then
Edit.
5. On the Edit Graph screen, in the lower half of the screen, choose the graph's title.
6. In the Title field, type a new name, choose Save, and then in the lower-right corner of the Edit
Graph screen, choose Save.
Add, Edit, or Remove a Text Widget from a
Dashboard
You can add a text widget, which is a block of text, to your dashboard. You can format the text in the
text widget using Markdown.
To add a text widget to a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, select a dashboard, and then choose Add widget.
4. In the Add widget to dashboard dialog box, choose Text widget and then Configure.
5. In the New text widget dialog box, in the Markdown field, add and format your text using
Markdown, and then choose Create widget.
6. Choose Save dashboard.
To edit a text widget on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. In the dashboard, hover over the upper-right corner of the text block to edit, choose Widget
actions and then Edit.
5. In the Edit text widget dialog box, update the text as needed, and then choose Update widget.
33
Amazon CloudWatch User Guide
Create a Cross-Region Dashboard
6. Choose Save dashboard.
To remove a text widget from a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. In the dashboard, hover over the upper-right corner of the text block, choose Widget actions and
then Delete.
5. Choose Save dashboard.
Create a Cross-Region Dashboard
You can monitor multiple resources in different locations on a single dashboard. For example, you
might want to create a dashboard showing CPU utilization for an Amazon EC2 instance located in the
us-west-2 region with your billing metrics, which are located in us-east-1 region.
To create a cross-region dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change to the region where your resources are located. From the navigation bar,
select the region that meets your needs. For more information, see Regions and Endpoints in the
Amazon Web Services General Reference.
3. In the navigation pane, choose Metrics.
4. In the contents pane, select the metric that you want to add to your dashboard.
5. In the lower pane, choose Add to Dashboard.
6. In the Add to dashboard dialog box, in the Add to list, select the dashboard that you want to add
the graph to, and then choose Add to dashboard.
7. To add other regions, metrics, or resources, repeat these steps as needed.
8. Choose Save dashboard.
Switch Between Dashboards
You can switch from one dashboard to another.
To switch between dashboards dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
Note
Your most recently accessed dashboard is listed under Dashboards in the navigation
pane.
3. In the Dashboards list, choose a dashboard.
Link and Unlink Graphs on a Dashboard
You can link all of the graphs on your dashboard together, so that when you zoom in or zoom out on
one graph, all of the other graphs zoom in or zoom out at the same time. You can unlink graphs to limit
changes to one graph.
34
Amazon CloudWatch User Guide
Change the Dashboard Refresh Interval
To link or unlink graphs on a dashboard
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. On the Actions menu, do one of the following:
a. To link all graphs together, select Link graphs.
b. To unlink all graphs, clear Link graphs.
Change the Dashboard Refresh Interval
You can change how often the dashboard data is refreshed.
To change the dashboard refresh interval
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. On the Refresh options menu (upper right corner of the console), do one of the following:
a. To automatically refresh the dashboard, select Auto refresh.
b. To change the refresh interval, under Refresh interval, choose 1, 2, 5, or 15 minutes.
Change the Dashboard Time Range, Period, or
Time Format
You can change the time range to display dashboard data over minutes, hours, or days. You can also
change the period to change the granularity of the data presented. In addition, you can change the time
format to display dashboard data in UTC or local time format.
To change the dashboard time range
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. On the Minutes, Hours, Days menu (upper right corner of the console), under Time range,
choose a value for Minutes, Hours, or Days.
To change the dashboard period
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
3. In the Dashboards list, choose a dashboard.
4. On the Minutes, Hours, Days menu (upper right corner of the console), under Period, choose
one of the available options.
To change the dashboard time format
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. In the navigation pane, choose Dashboards.
35
Amazon CloudWatch User Guide
Change the Dashboard Time
Range, Period, or Time Format
3. In the Dashboards list, choose a dashboard.
4. On the Minutes, Hours, Days menu (upper right corner of the console), under Time zone, choose
Local or UTC.
36
Amazon CloudWatch User Guide
View Available Metrics
Viewing, Graphing, and
Publishing Metrics
Metrics are data about the performance of your systems. By default, a set of free metrics is provided
for Amazon Elastic Compute Cloud (Amazon EC2) instances, Amazon Elastic Block Store (Amazon
EBS) volumes, Amazon Relational Database Service (Amazon RDS) DB instances, and Elastic Load
Balancing. You can also choose to enable detailed monitoring for your Amazon EC2 instances, or
add your own application metrics. Metric data is kept for a period of two weeks enabling you to view
up-to-the-minute data and also historical data. Amazon CloudWatch can load all the metrics in your
account for search, graphing and alarms with the AWS Management Console. This includes both AWS
resource metrics and application metrics that you provide.
You can use the following procedures to graph metrics in CloudWatch. After you have completed these
procedures, you can then create alarms for a metric. For more information, see Creating Amazon
CloudWatch Alarms (p. 76).
Topics
View Available Metrics (p. 37)
Search for Available Metrics (p. 40)
Select and Deselect Metrics (p. 41)
Get Statistics for a Metric (p. 44)
Graph Metrics (p. 60)
Publish Custom Metrics (p. 73)
View Available Metrics
Only those services in AWS that you're using send metrics to Amazon CloudWatch. You can use the
Amazon CloudWatch console, the list-metrics command, or the ListMetrics API to view the
available metrics.
AWS Management Console
To view available metrics by category
You can view metrics by category. Metrics are grouped first by Namespace, and then by the various
Dimension combinations within each Namespace. For example, you can view all EC2 metrics, or EC2
metrics grouped by instance ID, instance type, image (AMI) ID, or Auto Scaling Group.
37
Amazon CloudWatch User Guide
Command Line Tools
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, under EC2 Metrics, select Per-Instance Metrics,
and then in the upper pane, scroll down to view the full list of metrics.
Command Line Tools
To list available metrics across multiple Amazon EC2 instances
38
Amazon CloudWatch User Guide
Command Line Tools
Enter the list-metrics command.
Prompt>aws cloudwatch list-metrics --namespace "AWS/EC2"
The AWS CLI returns the following:
{
"Metrics": [
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-dd8855ba"
}
],
"MetricName": "DiskReadBytes"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-0b12b76c"
}
],
"MetricName": "CPUUtilization"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [],
"MetricName": "NetworkIn"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-e31dbd84"
}
],
"MetricName": "DiskReadOps"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-13bf6574"
}
],
"MetricName": "DiskWriteBytes"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
39
Amazon CloudWatch User Guide
Query API
"Name": "InstanceId",
"Value": "i-2840c24f"
}
],
"MetricName": "DiskReadOps"
},
{
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "InstanceId",
"Value": "i-9960c1fe"
}
],
"MetricName": "NetworkOut"
}
}
Query API
To determine available metrics across multiple instances
Call ListMetrics to generate a list of all of your valid metrics.
This returns a list of metrics. An example metric might look like the following:
MetricName = CPUUtilization
Dimensions (Name=InstanceId, Value=i-5431413d)
Namespace = AWS/EC2
Search for Available Metrics
You can search within all the metrics in your account using targeted search terms. Metrics are returned
that have matching results within their Namespace, Metric Name, or Dimensions.
To search for available metrics in CloudWatch
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
40
Amazon CloudWatch User Guide
Select and Deselect Metrics
4. In the CloudWatch Metrics by Category pane, in the Search Metrics field, type a search term,
metric name, service name, etc. and press enter.
For example, you can enter volume in the Search Metrics field, which returns all metrics with the
word volume in their name.
Select and Deselect Metrics
You can select and deselect metrics in the CloudWatch console in many different ways. When you
select metrics, they automatically appear in a graph in the details pane, so it's useful to know how to
select or deselect metrics to graph the data you want.
To select or deselect metrics
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
41
Amazon CloudWatch User Guide
Select and Deselect Metrics
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a metrics category or in the Search
Metrics field, type a search term, metric name, service name, and so on and press Enter.
For example, you can enter volume in the Search Metrics field, which returns all metrics with the
word volume in their name.
5. Do one of the following:
To select or deselect an individual metric, in the results pane, select the check box next to the
resource name and metric.
To select all metrics in the list, in the results pane, at the top of the list, click Select All.
To deselect all metrics, in the results pane, at the top of the metrics list, click Clear.
To list all resources that use a metric, in the results pane, in the Metric Name column, click a
metric. 42
Amazon CloudWatch User Guide
Select and Deselect Metrics
This is useful when you want to see all of these resources on the same graph. For more
information, see Graph a Metric Across Resources (p. 61).
To deselect all but one metric, in the results pane, in the metrics list, click the space between the
resource type and the metric name of the metric you want to keep selected.
To view a list of all selected metrics, in the navigation pane, under Metrics, click Selected
Metrics.
43
Amazon CloudWatch User Guide
Get Statistics for a Metric
Get Statistics for a Metric
This set of scenarios shows you how you can use the AWS Management Console, the get-metric-
statistics command, or the GetMetricStatistics API to get a variety of statistics.
Note
Start and end times must be within the last 14 days.
Topics
Get Statistics for a Specific EC2 Instance (p. 44)
Aggregating Statistics Across Instances (p. 48)
Get Statistics Aggregated by Auto Scaling Group (p. 53)
Get Statistics Aggregated by Amazon Machine Image (AMI) ID (p. 55)
Get Statistics for a Specific EC2 Instance
The following table describes the types of monitoring data available for your Amazon EC2 instances.
Monitoring Type Description
Basic Data is available automatically in 5-minute periods at no charge.
Detailed Data is available in 1-minute periods at an additional cost. To get this level
of data, you must specifically enable it for the instance. For the instances
where you've enabled detailed monitoring, you can also get aggregated
data across groups of similar instances.
For information about pricing, go to the Amazon CloudWatch product page.
The following scenario walks you through how to use the AWS Management Console, the get-
metric-statistics command, or the GetMetricStatistics API to determine the maximum
CPU utilization of a specific EC2 instance. For more information about monitoring EC2 instances, see
Monitoring Your Instances with CloudWatch in the Amazon EC2 User Guide for Linux Instances.
Note
Start and end times must be within the last 14 days.
For this example, we assume that you have an EC2 instance ID. You can get an active EC2 instance
ID using the AWS Management Console.
AWS Management Console
To display the average CPU utilization for a specific instance
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select EC2: Metrics.
The metrics available for individual instances appear in the upper pane.
5. Select a row that contains CPUUtilization for a specific InstanceId.
A graph showing average CPUUtilization for a single instance appears in the details pane.
44
Amazon CloudWatch User Guide
Get Statistics for a Specific EC2 Instance
6. To change the Statistic, e.g., Average, for the metric, choose a different value from the pop-up
list.
7. To change the Period, e.g., 5 Minutes, to view data in more granular detail, choose a different
value from the pop-up list.
45
Amazon CloudWatch User Guide
Get Statistics for a Specific EC2 Instance
Command Line Tools
To get the CPU utilization per EC2 instance
Enter the get-metric-statistics command with the following parameters
Prompt>aws cloudwatch get-metric-statistics --metric-name CPUUtilization
--start-time 2014-02-18T23:18:00 --end-time 2014-02-19T23:18:00
--period 360 --namespace AWS/EC2 --statistics Maximum --dimensions
Name=InstanceId,Value=<your-instance-id>
The AWS CLI returns the following:
{
"Datapoints": [
{
"Timestamp": "2014-02-19T00:18:00Z",
"Maximum": 0.33000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T03:18:00Z",
"Maximum": 99.670000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T07:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T12:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T02:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T01:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T17:18:00Z",
"Maximum": 3.3900000000000001,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T13:18:00Z",
"Maximum": 0.33000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-18T23:18:00Z",
46
Amazon CloudWatch User Guide
Get Statistics for a Specific EC2 Instance
"Maximum": 0.67000000000000004,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T06:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T11:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T10:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T19:18:00Z",
"Maximum": 8.0,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T15:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T14:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T16:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T09:18:00Z",
"Maximum": 0.34000000000000002,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T04:18:00Z",
"Maximum": 2.0,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T08:18:00Z",
"Maximum": 0.68000000000000005,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-19T05:18:00Z",
"Maximum": 0.33000000000000002,
"Unit": "Percent"
},
{
47
Amazon CloudWatch User Guide
Aggregating Statistics Across Instances
"Timestamp": "2014-02-19T18:18:00Z",
"Maximum": 6.6699999999999999,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
The returned statistics are six-minute values for the requested two-day time interval. Each value
represents the maximum CPU utilization percentage for a single EC2 instance.
Query API
To get the CPU utilization per hour for an EC2 instance for a 3-day range
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Period = 3600
Statistics list includes Maximum
Dimensions (Name=InstanceId, Value="<your-instance-id>")
Namespace = AWS/EC2
StartTime = 2011-01-09T23:18:00
EndTime = 2011-01-12T23:18:00
Aggregating Statistics Across Instances
Aggregate statistics are available for the instances that have detailed monitoring enabled. Instances
that use basic monitoring are not included in the aggregates. In addition, Amazon CloudWatch does
not aggregate data across regions. Therefore, metrics are completely separate between regions.
Before you can get statistics aggregated across instances, you must enable detailed monitoring (at
an additional charge), which provides data in 1-minute periods. This scenario shows you how to use
detailed monitoring with either the AWS Management Console, the GetMetricStatistics API,
or the get-metric-statistics command to get the average CPU usage for your EC2 instances.
Because no dimension is specified, CloudWatch returns statistics for all dimensions in the AWS/EC2
namespace. To get statistics for other metrics, see Amazon CloudWatch Namespaces, Dimensions,
and Metrics Reference (p. 140).
Important
This technique for retrieving all dimensions across an AWS namespace does not work for
custom namespaces that you publish to Amazon CloudWatch. With custom namespaces, you
must specify the complete set of dimensions that are associated with any given data point to
retrieve statistics that include the data point.
AWS Management Console
To display average CPU utilization for your Amazon EC2 instances
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, under EC2 Metrics, select Across All Instances.
48
Amazon CloudWatch User Guide
Aggregating Statistics Across Instances
The metrics available across all instances are displayed in the upper pane.
5. In the upper pane, select the row that contains CPUUtilization.
A graph showing CPUUtilization for your EC2 instances is displayed in the details pane.
6. To change the Statistic, e.g., Average, for the metric, choose a different value from the pop-up
list.
7. To change the Period, e.g., 5 Minutes, to view data in more granular detail, choose a different
value from the pop-up list.
49
Amazon CloudWatch User Guide
Aggregating Statistics Across Instances
Command Line Tools
To get average CPU utilization across your Amazon EC2 instances
Enter the get-metric-statistics command with the following parameters:
Prompt>aws cloudwatch get-metric-statistics --metric-name CPUUtilization
--start-time 2014-02-11T23:18:00 --end-time 2014-02-12T23:18:00 --period
3600 --namespace AWS/EC2 --statistics "Average" "SampleCount"
The AWS CLI returns the following:
{
"Datapoints": [
{
"SampleCount": 238.0,
"Timestamp": "2014-02-12T07:18:00Z",
"Average": 0.038235294117647062,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T09:18:00Z",
"Average": 0.16670833333333332,
"Unit": "Percent"
},
{
"SampleCount": 238.0,
"Timestamp": "2014-02-11T23:18:00Z",
"Average": 0.041596638655462197,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T16:18:00Z",
"Average": 0.039458333333333345,
"Unit": "Percent"
},
{
"SampleCount": 239.0,
"Timestamp": "2014-02-12T21:18:00Z",
"Average": 0.041255230125523033,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T01:18:00Z",
"Average": 0.044583333333333336,
"Unit": "Percent"
},
{
"SampleCount": 239.0,
"Timestamp": "2014-02-12T18:18:00Z",
"Average": 0.043054393305439344,
"Unit": "Percent"
},
{
50
Amazon CloudWatch User Guide
Aggregating Statistics Across Instances
"SampleCount": 240.0,
"Timestamp": "2014-02-12T13:18:00Z",
"Average": 0.039458333333333345,
"Unit": "Percent"
},
{
"SampleCount": 238.0,
"Timestamp": "2014-02-12T15:18:00Z",
"Average": 0.041260504201680689,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T19:18:00Z",
"Average": 0.037666666666666668,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T06:18:00Z",
"Average": 0.037541666666666675,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T20:18:00Z",
"Average": 0.039333333333333338,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T08:18:00Z",
"Average": 0.039250000000000014,
"Unit": "Percent"
},
{
"SampleCount": 239.0,
"Timestamp": "2014-02-12T03:18:00Z",
"Average": 0.037740585774058588,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T11:18:00Z",
"Average": 0.039500000000000007,
"Unit": "Percent"
},
{
"SampleCount": 238.0,
"Timestamp": "2014-02-12T02:18:00Z",
"Average": 0.039789915966386563,
"Unit": "Percent"
},
{
"SampleCount": 238.0,
"Timestamp": "2014-02-12T22:18:00Z",
"Average": 0.039705882352941181,
"Unit": "Percent"
},
51
Amazon CloudWatch User Guide
Aggregating Statistics Across Instances
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T14:18:00Z",
"Average": 0.082458333333333328,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T05:18:00Z",
"Average": 0.04287500000000001,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T17:18:00Z",
"Average": 0.039458333333333345,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T10:18:00Z",
"Average": 0.083416666666666667,
"Unit": "Percent"
},
{
"SampleCount": 236.0,
"Timestamp": "2014-02-12T00:18:00Z",
"Average": 0.036567796610169498,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T12:18:00Z",
"Average": 0.039541666666666676,
"Unit": "Percent"
},
{
"SampleCount": 240.0,
"Timestamp": "2014-02-12T04:18:00Z",
"Average": 0.043000000000000003,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
Query API
To get average CPU utilization for your Amazon EC2 instances
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Statistics list includes Average
Namespace = AWS/EC2
StartTime = 2011-01-10T23:18:00
52
Amazon CloudWatch User Guide
Get Statistics Aggregated by Auto Scaling Group
EndTime = 2011-01-12T23:18:00
Period = 360
The returned statistics are six-minute values for the two-day interval.
Get Statistics Aggregated by Auto Scaling
Group
Aggregate statistics are available for instances that are within an Auto Scaling group. Amazon
CloudWatch does not aggregate data across regions. Therefore, metrics are completely separate
between regions.
This scenario shows you how to use the AWS Management Console, the get-metric-statistics
command, or the GetMetricStatistics API with the DiskWriteBytes metric to retrieve the total
bytes written to disk for one Auto Scaling group. The total is computed for one-minute periods for a 24-
hour interval across all EC2 instances in the specified AutoScalingGroupName.
Note
Start and end times must be within the last 14 days.
AWS Management Console
To display total DiskWriteBytes for an autoscaled EC2 application
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, under EC2 Metrics, select By Auto Scaling
Group.
The metrics available for Auto Scaling groups are displayed in the upper pane.
5. Select the row that contains DiskWriteBytes.
A graph showing DiskWriteBytes for all EC2 instances appears in the details pane.
53
Amazon CloudWatch User Guide
Get Statistics Aggregated by Auto Scaling Group
6. To change the Statistic, e.g., Average, for the metric, choose a different value from the pop-up
list.
7. To change the Period, e.g., 5 Minutes, to view data in more granular detail, choose a different
value from the pop-up list.
Command Line Tools
To get total DiskWriteBytes for an autoscaled EC2 application
Enter the get-metric-statistics command with the following parameters.
54
Amazon CloudWatch User Guide
Get Statistics Aggregated by
Amazon Machine Image (AMI) ID
Prompt>aws cloudwatch get-metric-statistics --metric-name DiskWriteBytes
--start-time 2014-02-16T23:18:00 --end-time 2014-02-18T23:18:00 --period
360 --namespace AWS/EC2 --statistics "Sum" "SampleCount" --dimensions
Name=AutoScalingGroupName,Value=test-group-1
The AWS CLI returns the following:
{
"Datapoints": [
{
"SampleCount": 18.0,
"Timestamp": "2014-02-19T21:36:00Z",
"Sum": 0.0,
"Unit": "Bytes"
},
{
"SampleCount": 5.0,
"Timestamp": "2014-02-19T21:42:00Z",
"Sum": 0.0,
"Unit": "Bytes"
}
],
"Label": "DiskWriteBytes"
}
Query API
To get total DiskWriteBytes for an autoscaled EC2 application
Call GetMetricStatistics with the following parameters:
MetricName = DiskWriteBytes
Period = 60
Statistics list includes Sum
Unit = Bytes
Dimensions (Name=AutoScalingGroupName, Value=test-group-1)
Namespace = AWS/EC2
StartTime = 2011-01-10T23:18:00
EndTime = 2011-01-11T23:18:00
The statistics returned are one-minute totals for bytes written for the entire Auto Scaling group
over the 24-hour interval.
Get Statistics Aggregated by Amazon Machine
Image (AMI) ID
Aggregate statistics are available for the instances that have detailed monitoring enabled. Instances
that use basic monitoring are not included in the aggregates. In addition, Amazon CloudWatch does
not aggregate data across regions. Therefore, metrics are completely separate between regions.
55
Amazon CloudWatch User Guide
Get Statistics Aggregated by
Amazon Machine Image (AMI) ID
Before you can get statistics aggregated across instances, you must enable detailed monitoring (at an
additional charge), which provides data in 1-minute periods.
This scenario shows you how to use the AWS Management Console, the get-metric-statistics
command, or the GetMetricStatistics API to determine average CPU utilization for all instances
that match a given image ID. The average is over 60-second time intervals for a one-day period.
Note
Start and end times must be within the last 14 days.
In this scenario the EC2 instances are running an image ID of ami-4dd1a224.
AWS Management Console
To display the average CPU utilization for an image (AMI) ID
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, under EC2 Metrics, select By Image (AMI) Id.
The metrics available for image IDs appear in the upper pane.
5. Select a row that contains CPUUtilization and an image ID.
A graph showing average CPUUtilization for all EC2 instances based on the ami-4dd1a224
image ID appears in the details pane.
6. To change the Statistic, e.g., Average, for the metric, choose a different value from the pop-up
list.
56
Amazon CloudWatch User Guide
Get Statistics Aggregated by
Amazon Machine Image (AMI) ID
7. To change the Period, e.g., 5 Minutes, to view data in more granular detail, choose a different
value from the pop-up list.
Command Line Tools
To get the average CPU utilization for an image (AMI) ID
Enter the get-metric-statistics command as in the following example.
Prompt>aws cloudwatch get-metric-statistics --metric-name CPUUtilization
--start-time 2014-02-10T00:00:00 --end-time 2014-02-11T00:00:00 --
period 3600 --statistics Average --namespace AWS/EC2 --dimensions
Name=ImageId,Value=ami-3c47a355
The AWS CLI returns the following:
{
"Datapoints": [
{
"Timestamp": "2014-02-10T07:00:00Z",
"Average": 0.041000000000000009,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T14:00:00Z",
"Average": 0.079579831932773085,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T06:00:00Z",
"Average": 0.036000000000000011,
"Unit": "Percent"
57
Amazon CloudWatch User Guide
Get Statistics Aggregated by
Amazon Machine Image (AMI) ID
},
{
"Timestamp": "2014-02-10T13:00:00Z",
"Average": 0.037625000000000013,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T18:00:00Z",
"Average": 0.042750000000000003,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T21:00:00Z",
"Average": 0.039705882352941188,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T20:00:00Z",
"Average": 0.039375000000000007,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T02:00:00Z",
"Average": 0.041041666666666671,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T01:00:00Z",
"Average": 0.041083333333333354,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T23:00:00Z",
"Average": 0.038016877637130804,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T15:00:00Z",
"Average": 0.037666666666666668,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T12:00:00Z",
"Average": 0.039291666666666676,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T03:00:00Z",
"Average": 0.036000000000000004,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T04:00:00Z",
"Average": 0.042666666666666672,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T19:00:00Z",
"Average": 0.038305084745762719,
58
Amazon CloudWatch User Guide
Get Statistics Aggregated by
Amazon Machine Image (AMI) ID
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T22:00:00Z",
"Average": 0.039291666666666676,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T09:00:00Z",
"Average": 0.17126050420168065,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T08:00:00Z",
"Average": 0.041166666666666678,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T11:00:00Z",
"Average": 0.082374999999999962,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T17:00:00Z",
"Average": 0.037625000000000013,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T10:00:00Z",
"Average": 0.039458333333333345,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T05:00:00Z",
"Average": 0.039250000000000007,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T00:00:00Z",
"Average": 0.037625000000000013,
"Unit": "Percent"
},
{
"Timestamp": "2014-02-10T16:00:00Z",
"Average": 0.041512605042016815,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
The operation returns statistics that are one-minute values for the one-day interval. Each value
represents an average CPU utilization percentage for EC2 instances running the specified machine
image.
59
Amazon CloudWatch User Guide
Graph Metrics
Query API
To get the average CPU utilization for an image (AMI) ID
Call GetMetricStatistics with the following parameters:
MetricName = CPUUtilization
Period = 60
Statistics list includes Average
Dimensions (Name= ImageId, Value= ami-c5e40dac)
Namespace = AWS/EC2
StartTime = 2011-01-10T00:00:00
EndTime = 2011-01-11T00:00:00
Graph Metrics
You can use the CloudWatch console to graph metric data generated by other AWS services to make
it easier to see the metric activity on your services. You can use the following procedures to graph
metrics in CloudWatch.
Topics
Graph a Metric (p. 60)
Graph a Metric Across Resources (p. 61)
Graph Several Metrics (p. 63)
Modify the Date and Time on a Graph (p. 64)
Modify the Statistic for a Graph (p. 65)
Modify the Period for a Graph (p. 66)
Modify a Graph's Title (p. 67)
Create an Alarm from a Metric on a Graph (p. 68)
Zoom in to a Graph (p. 69)
Switch the Y-Axis for a Metric (p. 70)
Set custom bounds for the Y-Axis on a graph (p. 71)
Save a Graph (p. 72)
Graph a Metric
You can select a metric and create a graph of the data in CloudWatch. For example, you can select
the CPUUtilization metric for an Amazon EC2 instance and display a graph of CPU usage over time for
that instance.
To graph a metric
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, use the Search Metrics field and categories to
find a metric using the metric name, AWS resource, or other metadata.
60
Amazon CloudWatch User Guide
Graph a Metric Across Resources
5. Use the scroll bar and next and previous arrows above the metrics list to page through the full list
of metrics
6. Select the metric to view, for example, CPUUtilization. A graph appears in the details pane.
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Graph a Metric Across Resources
You can graph a metric across all resources to see everything on one graph. For example, you can
graph the CPUUtilization metric for all Amazon EC2 instances on one graph.
To graph a metric across resources
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Metrics.
61
Amazon CloudWatch User Guide
Graph a Metric Across Resources
4. In the CloudWatch Metrics by Category pane, select a metric category. For example, under EC2
Metrics, select Per-Instance Metrics.
5. In the metric list, in the Metric Name column, click a metric. For example CPUUtilization.
6. At the top of the metric list, click Select All.
The graph shows all data for all occurrences of the selected metric. In the example below,
CPUUtilization for all Amazon EC2 instances is shown.
62
Amazon CloudWatch User Guide
Graph Several Metrics
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Graph Several Metrics
You can graph several metrics over time on the same graph. For example, you can graph
CPUUtilization and DiskReadBytes for an Amazon EC2 instance and show them together on the same
graph.
To graph several metrics
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, use the Search Metrics field and categories to
find a metric using the metric name, AWS resource, or other metadata.
5. Select the check box next to each metric you want to graph. You can add additional metrics by
selecting their check boxes. A line appears on the graph for each check box you select.
63
Amazon CloudWatch User Guide
Modify the Date and Time on a Graph
6. To clear your selections and view data for a single metric, click the metric name in the list.
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Modify the Date and Time on a Graph
You can change the date and time on a graph to view data at different points in time.
To modify the date and time on a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. In the details pane, in the Time Range section, select a new date range using the From and To
fields.
64
Amazon CloudWatch User Guide
Modify the Statistic for a Graph
7. Click Update Graph or the refresh (circular arrows) button to update the graph with the new date
range.
8. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Modify the Statistic for a Graph
CloudWatch supports several different statistics on metrics: Average, Minimum, Maximum, Sum &
Samples. For more information, see Statistics (p. 7).
To modify the statistic for a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. Next to the graph's title, click the Statistic drop down list and then select a statistic, for example,
Maximum.
The graph updates with the new selection.
65
Amazon CloudWatch User Guide
Modify the Period for a Graph
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Modify the Period for a Graph
CloudWatch enables you to view your data at different granularities. You can view your data using
Period of 1 minute, giving you a very detailed view. This is very useful when troubleshooting, when
viewing narrow bands of time (e.g. 1 hour), and when performing other activities that require the most
precise graphing of time periods. You can also view your data using Period of 1 hour, giving you a less
detailed view. This is very useful when viewing wider bands of time (e.g. 3 days), and allows you to see
trends over time. For more information, see Periods (p. 7).
To modify the period for a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. Click the Period drop down list and then select a new period, for example, 5 Minutes.
The graph updates with the new selection.
66
Amazon CloudWatch User Guide
Modify a Graph's Title
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Modify a Graph's Title
CloudWatch provides a default title for any graph you create. You can edit the title and change it if you
want.
To modify a graph's title
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. In the details pane, click the title to edit it.
7. In the pop-up box, enter a new title, and then click Save to update the graph's title.
67
Amazon CloudWatch User Guide
Create an Alarm from a Metric on a Graph
Create an Alarm from a Metric on a Graph
You can graph a metric and then create an alarm from the metric on the graph, which has the benefit of
populating many of the alarm fields for you.
To create an alarm from a metric on a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box next to the metric for which you want to create an alarm.
6. In the details pane, under Actions, click Create Alarm, and then complete the alarm fields.
For more information about how to create an alarm, see Creating Amazon CloudWatch
Alarms (p. 76).
68
Amazon CloudWatch User Guide
Zoom in to a Graph
Zoom in to a Graph
You can change the granularity of a graph and zoom in to see data over a shorter time period.
To zoom in to a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. In the details pane, click and drag on the graph area, and then release your mouse button.
The graph updates with the new selection.
69
Amazon CloudWatch User Guide
Switch the Y-Axis for a Metric
7. To save this graph and access it later, in the details pane, under Actions, click Copy URL, and
then in the Copy Graph URL dialog box, select the URL and paste it into your browser.
Switch the Y-Axis for a Metric
You can display multiple metrics on a single graph using two different Y-axes. This is particularly useful
for metrics that have different units or that differ greatly in their range of values.
To switch the Y-Axis for a metric
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics.
6. In the details pane, hover over a line on the graph or the legend entry for the metric and a hover
box appears.
7. Click the switch link in the hover box. The metric switches to the opposite axis.
70
Amazon CloudWatch User Guide
Set custom bounds for the Y-Axis on a graph
Set custom bounds for the Y-Axis on a graph
You can set custom bounds for the Y-axis on a graph to help you see the data better. For example,
you might want to change the bounds on a CPUUtilization graph to 100 percent so that when you look
at the graph, it’s very clear if CPU is low (the plotted line is near the bottom of the graph) or high (the
plotted line is near the top of the graph).
To set custom bounds for the Y-Axis on a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, select a category to view available metrics.
5. Select the check box for one or more metrics to automatically graph them.
6. To the right of the graph, expand the Left Y-axis section and enter values into the Min and Max
fields. The value in the Min field must be less than but not equal to the value in the Max field.
71
Amazon CloudWatch User Guide
Save a Graph
7. To set custom bounds for the right Y-axis, hover over a line in the graph until the legend appears.
In the legend, click switch.
8. Expand the Right Y-axis section and enter values into the Min and Max fields.
Save a Graph
You can save, or bookmark, a graph to access it later.
To save a graph
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Metrics.
4. In the CloudWatch Metrics by Category pane, use the Search Metrics field and categories to
find a metric by metric name, AWS resource, or other metadata.
5. Use the scroll bar and next and previous arrows above the metrics list to page through the full list
of metrics
6. Select the metric to view. In the example below, a graph for an Amazon EC2 instance's
CPUUtilization metric is displayed in the details pane.
72
Amazon CloudWatch User Guide
Publish Custom Metrics
7. In the details pane, under Actions, click Copy URL.
8. In the Copy Graph URL dialog box, select the URL and paste it into your browser.
Using your browser, bookmark the page to access it later.
Publish Custom Metrics
You can publish your own metrics to CloudWatch with the put-metric-data command (or its Query
API equivalent PutMetricData). For more information, see put-metric-data in the AWS Command
Line Interface Reference. You can view statistical graphs of your published metrics with the AWS
Management Console.
If you call put-metric-data with a new metric name, CloudWatch creates a new metric for you.
Otherwise, CloudWatch associates your data with the existing metric that you specify.
Note
When you create a new metric using the put-metric-data command, it can take up to
two minutes before you can retrieve statistics on the new metric using the get-metric-
statistics command. However, it can take up to fifteen minutes before the new metric
appears in the list of metrics retrieved using the list-metrics command.
CloudWatch stores data about a metric as a series of data points. Each data point has an associated
time stamp. You can publish one or more data points with each call to put-metric-data. You can
even publish an aggregated set of data points called a statistics set.
Topics
Publish Single Data Points (p. 74)
Publish Statistic Sets (p. 75)
Publish the Value Zero (p. 75)
73
Amazon CloudWatch User Guide
Publish Single Data Points
Publish Single Data Points
To publish a single data point for a new or existing metric, use the put-metric-data command with
one value and time stamp. For example, the following actions each publish one data point:
aws cloudwatch put-metric-data --metric-name PageViewCount --namespace
"MyService" --value 2 --timestamp 2014-02-14T12:00:00.000Z
aws cloudwatch put-metric-data --metric-name PageViewCount --namespace
"MyService" --value 4 --timestamp 2014-02-14T12:00:01.000Z
aws cloudwatch put-metric-data --metric-name PageViewCount --namespace
"MyService" --value 5 --timestamp 2014-02-14T12:00:02.000Z
Note
The put-metric-data command can only publish one data point per call. If you want to run
this example, specify time stamps within the past two weeks.
Although you can publish data points with time stamps as granular as one-thousandth of a second,
CloudWatch aggregates the data to a minimum granularity of one minute. CloudWatch records the
average (sum of all items divided by number of items) of the values received for every 1-minute period,
as well as number of samples, maximum value, and minimum value for the same time period. For
example, the PageViewCount metric from the previous examples contains three data points with time
stamps just seconds apart. CloudWatch aggregates the three data points because they all have time
stamps within a one-minute period.
CloudWatch uses one-minute boundaries when aggregating data points. For example,
CloudWatch aggregates the data points from the previous example because all three data points
fall within the one-minute period that begins at 2014-02-20T12:00:00.000Z and ends at
2014-02-20T12:01:00.000Z.
You can use the get-metric-statistics command to retrieve statistics based on the data points
you have published.
aws cloudwatch get-metric-statistics --metric-name PageViewCount --
namespace "MyService" --statistics "Sum" "Maximum" "Minimum" "Average"
"SampleCount" --period 60 --start-time 2014-02-20T12:00:00.000Z --end-
time 2014-02-20T12:05:00.000Z --output json
CloudWatch returns the following:
{
"Datapoints": [
{
"SampleCount": 3.0,
"Timestamp": "2014-02-20T12:00:00Z",
"Average": 3.6666666666666665,
"Maximum": 5.0,
"Minimum": 2.0,
"Sum": 11.0,
"Unit": "None"
}
],
"Label": "PageViewCount"
}
74
Amazon CloudWatch User Guide
Publish Statistic Sets
Publish Statistic Sets
You can also aggregate your data before you publish to CloudWatch. When you have multiple
data points per minute, aggregating data minimizes the number of calls to put-metric-data. For
example, instead of calling put-metric-data multiple times for three data points that are within three
seconds of each other, you can aggregate the data into a statistic set that you publish with one call:
aws cloudwatch put-metric-data --metric-name PageViewCount --namespace
"MyService" --statistic-value Sum=11,Minimum=2,Maximum=5,SampleCount=3 --
timestamp 2014-02-14T12:00:00.000Z
Publish the Value Zero
When your data is more sporadic and you have periods that have no associated data, you can choose
to publish the value zero (0) for that period or no value at all. You might want to publish zero instead
of no value if you use periodic calls to PutMetricData to monitor the health of your application. For
example, you can set a CloudWatch alarm to notify you if your application fails to publish metrics every
five minutes. You want such an application to publish zeros for periods with no associated data.
You might also publish zeros if you want to track the total number of data points or if you want statistics
such as minimum and average to include data points with the value 0.
75
Amazon CloudWatch User Guide
Creating Amazon CloudWatch
Alarms
You can create a CloudWatch alarm that sends an Amazon Simple Notification Service message
when the alarm changes state. An alarm watches a single metric over a time period you specify, and
performs one or more actions based on the value of the metric relative to a given threshold over a
number of time periods. The action is a notification sent to an Amazon Simple Notification Service topic
or Auto Scaling policy. Alarms invoke actions for sustained state changes only. CloudWatch alarms will
not invoke actions simply because they are in a particular state, the state must have changed and been
maintained for a specified number of periods.
After an alarm invokes an action due to a change in state, its subsequent behavior depends on the
type of action that you have associated with the alarm. For Auto Scaling policy notifications, the alarm
continues to invoke the action for every period that the alarm remains in the new state. For Amazon
Simple Notification Service notifications, no additional actions are invoked.
An alarm has three possible states:
OK—The metric is within the defined threshold
ALARM—The metric is outside of the defined threshold
INSUFFICIENT_DATA—The alarm has just started, the metric is not available, or not enough data is
available for the metric to determine the alarm state
In the following figure, the alarm threshold is set to 3 and the evaluation period is 3. That is, the alarm
invokes its action if the oldest period is breaching and the others are breaching or missing within a time
window of 3 periods. In the figure, this happens with the third through fifth time periods, and the alarm's
state is set to ALARM. At period six, the value dips below the threshold, and the state reverts to OK.
Later, during the ninth time period, the threshold is breached again, but the previous periods are OK.
Consequently, the alarm's state remains OK.
76
Amazon CloudWatch User Guide
Note
CloudWatch doesn't test or validate the actions you specify, nor does it detect any Auto
Scaling or SNS errors resulting from an attempt to invoke nonexistent actions. Make sure your
actions exist.
Common Features of Alarms
You can create up to 5000 alarms per AWS account. To create or update an alarm, you use the
PutMetricAlarm API function (mon-put-metric-alarm command).
You can list any or all of the currently configured alarms, and list any alarms in a particular state
using the DescribeAlarms API (mon-describe-alarms command). You can further filter the list
by time range.
You can disable and enable alarms by using the DisableAlarmActions and
EnableAlarmActions APIs (mon-disable-alarm-actions and mon-enable-alarm-actions
commands).
You can test an alarm by setting it to any state using the SetAlarmState API (mon-set-alarm-
state command). This temporary state change lasts only until the next alarm comparison occurs.
You can create an alarm using the PutMetricAlarm API function (mon-put-metric-alarm
command) before you've created a custom metric. In order for the alarm to be valid, you must
include all of the dimensions for the custom metric in addition to the metric namespace and metric
name in the alarm definition.
Finally, you can view an alarm's history using the DescribeAlarmHistory API (mon-describe-
alarm-history command). CloudWatch preserves alarm history for two weeks. Each state
transition is marked with a unique time stamp. In rare cases, your history might show more than one
notification for a state change. The time stamp enables you to confirm unique state changes.
77
Amazon CloudWatch User Guide
Set Up Amazon Simple Notification Service
Note
Some AWS resources do not send metric data to CloudWatch under certain conditions.
For example, Amazon EBS may not send metric data for an available volume that is not
attached to an Amazon EC2 instance, because there is no metric activity to be monitored for
that volume. If you have an alarm set for such a metric, you may notice its state change to
Insufficient Data. This may simply be an indication that your resource is inactive, and may not
necessarily mean that there is a problem.
Topics
Set Up Amazon Simple Notification Service (p. 78)
Create or Edit an Alarm (p. 80)
Send Email Based on CPU Usage Alarm (p. 82)
Send Email Based on Load Balancer Alarm (p. 84)
Send Email Based on Storage Throughput Alarm (p. 86)
Create Alarms That Stop, Terminate, Reboot, or Recover an Instance (p. 88)
Monitor Your Estimated Charges Using Amazon CloudWatch (p. 101)
Set Up Amazon Simple Notification Service
Amazon CloudWatch uses Amazon Simple Notification Service (Amazon SNS) to send email. This
section shows you how to create and subscribe to an Amazon Simple Notification Service topic. When
you create a CloudWatch alarm, you can add this Amazon SNS topic to send an email notification
when the alarm changes state. For more information about Amazon Simple Notification Service, see
the Amazon Simple Notification Service Getting Started Guide.
Note
If you create your CloudWatch alarm with the AWS Management Console, you can skip
this procedure because you can create an Amazon Simple Notification Service topic in the
Configure Actions step in the Create Alarm Wizard.
Topics
AWS Management Console (p. 78)
Command Line Tools (p. 79)
AWS Management Console
To set up an Amazon Simple Notification Service topic with the AWS Management Console first you
create a topic, then you subscribe to it. You can then publish a message directly to the topic to ensure
that you have properly configured it.
To create an Amazon Simple Notification Service topic
1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. On the SNS dashboard, under Common actions, choose Create Topic.
4. In the Create new topic dialog box, in the Topic name field, enter the topic name MyTopic.
5. Click Create topic.
6. On the Topic details: MyTopic page, copy the Topic ARN for the next task.
78
Amazon CloudWatch User Guide
Command Line Tools
To subscribe to an Amazon Simple Notification Service topic
1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, choose Subscriptions.
4. On the Subscriptions page, choose Create subscription.
5. In the Create subscription dialog box, in the Topic ARN field, paste the topic ARN you created in
the previous task, for example: arn:aws:sns:us-east-1:111122223333:MyTopic.
6. In the Protocol drop-down list, choose Email.
7. In the Endpoint field, enter an email address you can use to receive the notification, and then click
Create subscription.
8. Go to your email application and open the message from AWS Notifications, and then click the link
to confirm your subscription.
Your web browser displays a confirmation response from Amazon Simple Notification Service.
To publish to an Amazon Simple Notification Service topic
1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, choose Topics.
4. On the Topics page, choose the topic you want to publish, and then choose Publish to topic.
5. In the
<guillabel>Publish a message</guillabel>
page, in the Subject field, enter a subject line for your message, and in the Message field, enter a
brief message.
6. Click Publish Message.
7. Check your email to confirm that you received the message from the topic.
Command Line Tools
This scenario walks you through how to use the AWS CLI to create an Amazon Simple Notification
Service topic, and then publish a message directly to the topic to ensure that you have properly
configured it. For information about how to install and configure the AWS CLI, see Getting Set Up with
the AWS Command Line Interface in the AWS Command Line Interface User Guide.
To set up an Amazon Simple Notification Service topic
1. Create the topic using the create-topic command. You receive a topic resource name as a
return value:
Prompt>aws sns create-topic --name MyTopic
Amazon Simple Notification Service returns the following Topic ARN:
{
"TopicArn": "arn:aws:sns:us-east-1:111122223333:MyTopic"
}
79
Amazon CloudWatch User Guide
Create or Edit an Alarm
2. Subscribe your email address to the topic using the subscribe command. You will receive a
confirmation email message if the subscription request succeeds.
Prompt>aws sns subscribe --topic-arn arn:aws:sns:us-
east-1:111122223333:MyTopic --protocol email --notification-
endpoint <your-email-address>
Amazon Simple Notification Service returns the following:
{
"SubscriptionArn": "pending confirmation"
}
3. Confirm that you intend to receive email from Amazon Simple Notification Service by clicking the
confirmation link in the body of the message to complete the subscription process.
4. Check the subscription using the list-subscriptions-by-topic command.
Prompt>aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-
east-1:111122223333:MyTopic
Amazon Simple Notification Service returns the following:
{
"Subscriptions": [
{
"Owner": "111122223333",
"Endpoint": "me@mycompany.com",
"Protocol": "email",
"TopicArn": "arn:aws:sns:us-east-1:111122223333:MyTopic",
"SubscriptionArn": "arn:aws:sns:us-
east-1:111122223333:MyTopic:64886986-bf10-48fb-a2f1-d
ab033aa67a3"
}
]
}
5. Publish a message directly to the topic using the publish command to ensure that the topic is
properly configured.
Prompt>aws sns publish --message "Verification" --topic arn:aws:sns:us-
east-1:111122223333:MyTopic
Amazon Simple Notification Service returns the following:
{
"MessageId": "42f189a0-3094-5cf6-8fd7-c2dde61a4d7d"
}
6. Check your email to confirm that you received the message from the topic.
Create or Edit an Alarm
You can create or edit an alarm from the Alarms list in the Amazon CloudWatch console.
80
Amazon CloudWatch User Guide
Create or Edit an Alarm
To create an alarm
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in the CloudWatch Metrics by Category pane, select a metric
category, for example, EC2 Metrics.
5. Select a metric, (for example, CPUUtilization), and then click Next.
6. Under Alarm Threshold, complete the fields, and then under Actions, select the type of action
you want the alarm to perform when the alarm is triggered.
You can choose specific metrics to trigger the alarm and specify thresholds for those metrics. You
can then set your alarm to change state when a metric exceeds a threshold that you have defined.
For an example of how to create an alarm that sends email, see Creating Amazon CloudWatch
Alarms (p. 76).
7. Click Create Alarm.
To edit an alarm
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
81
Amazon CloudWatch User Guide
Send Email Based on CPU Usage Alarm
3. In the navigation pane, click Alarms.
4. In the alarms list, select the check box next to the alarm you want to edit, and then click Modify.
5. In the Modify Alarm dialog box, update the alarm as necessary, and then click Save Changes.
To update an email notification list that was created using the CloudWatch console
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, click Alarms.
4. In the alarms list, select the check box next to the alarm you want to edit, and then click Modify.
5. In the Email list field, add or update the list of email addresses, and then click Save Changes.
To update an email notification list that was created in the Amazon SNS console
1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/.
2. If necessary, change the region. From the navigation bar, select the region that meets your
needs. For more information, see Regions and Endpoints in the Amazon Web Services General
Reference.
3. In the navigation pane, choose Topics, and then choose the arn for your notification list (topic).
4. Do one of the following:
To add an email address, choose Create subscription, in Protocol, choose Email, in
Endpoint, type the email address of the new recipient, and then choose Create subscription.
To remove an email address, choose the Subscription ID, choose Other subscription
actions, and then choose Delete subscriptions.
5. Choose Publish to topic.
Send Email Based on CPU Usage Alarm
This scenario walks you through how to use the AWS Management Console or the command line
tools to create an Amazon CloudWatch alarm that sends an Amazon Simple Notification Service email
message when the alarm changes state from OK to ALARM.
In this scenario, you configure the alarm to change to the ALARM state when the average CPU use of
an EC2 instance exceeds 70 percent for two consecutive five-minute periods.
Topics
AWS Management Console (p. 82)
Command Line Tools (p. 84)
AWS Management Console
To create an alarm that sends email based on CPU usage
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
82
Amazon CloudWatch User Guide
AWS Management Console
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in the CloudWatch Metrics by Category pane, select a metric
category, for example, EC2 Metrics.
5. In the list of metrics, select a row that contains CPUUtilization for a specific instance ID.
A graph showing average CPUUtilization for a single instance appears in the lower pane.
6. Select Average from the Statistic drop-down list.
7. Select a period from the Period drop-down list, for example: 5 minutes.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: myHighCpuAlarm.
9. In the Description field, enter a description of the alarm, for example: CPU usage exceeds 70
percent.
10. In the is drop-down list, select >.
11. In the box next to the is drop-down list, enter 70 and in the for field, enter 10.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, in the Whenever this alarm drop-down list, select State is ALARM.
13. In the Send notification to drop-down list, select an existing Amazon SNS topic or create a new
one.
14. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
myHighCpuAlarm, and in the Email list field, enter a comma-separated list of email addresses to
be notified when the alarm changes to the ALARM state.
15. In the navigation pane, click Create Alarm to complete the alarm creation process.
83
Amazon CloudWatch User Guide
Command Line Tools
Command Line Tools
To send an Amazon Simple Notification Service email message when CPU utilization
exceeds 70 percent
1. Set up an Amazon Simple Notification Service topic or retrieve the Topic Resource Name of the
topic you intend to use. For help on setting up an Amazon Simple Notification Service topic, see
Set Up Amazon Simple Notification Service (p. 78).
2. Create an alarm with the put-metric-alarm command. Use the values from the following
example, but replace the values for InstanceID and alarm-actions with your own values.
Prompt>aws cloudwatch put-metric-alarm --alarm-name cpu-mon --alarm-
description "Alarm when CPU exceeds 70%" --metric-name CPUUtilization
--namespace AWS/EC2 --statistic Average --period 300 --threshold
70 --comparison-operator GreaterThanThreshold --dimensions
Name=InstanceId,Value=i-12345678 --evaluation-periods 2 --alarm-
actions arn:aws:sns:us-east-1:111122223333:MyTopic --unit Percent
The AWS CLI returns to the command prompt if the command succeeds.
3. Test the alarm by forcing an alarm state change with the set-alarm-state command.
a. Change the alarm state from INSUFFICIENT_DATA to OK:
Prompt>aws cloudwatch set-alarm-state --alarm-name cpu-mon --state-
reason "initializing" --state-value OK
The AWS CLI returns to the command prompt if the command succeeds.
b. Change the alarm state from OK to ALARM:
Prompt>aws cloudwatch set-alarm-state --alarm-name cpu-mon --state-
reason "initializing" --state-value ALARM
The AWS CLI returns to the command prompt if the command succeeds.
c. Check that an email has been received.
Send Email Based on Load Balancer Alarm
This scenario walks you through how to use the Amazon CloudWatch console or the AWS command
line interface (CLI) to set up an Amazon Simple Notification Service notification and configure an alarm
that monitors load balancer latency exceeding 100 ms.
Topics
AWS Management Console (p. 84)
Command Line Tools (p. 86)
AWS Management Console
To create a load balancer alarm that sends email
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
84
Amazon CloudWatch User Guide
AWS Management Console
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in the CloudWatch Metrics by Category pane, select a metric
category, for example, ELB Metrics.
5. In the list of metrics, select a row that contains Latency for a specific load balancer.
A graph showing average Latency for a single load balancer appears in the lower pane.
6. Select Average from the Statistic drop-down list.
7. Select 1 Minute from the Period drop-down list.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: myHighCpuAlarm.
9. In the Description field, enter a description of the alarm, for example: Alarm when Latency
exceeds 100s.
10. In the is drop-down list, select >.
11. In the box next to the is drop-down list, enter 0.1 and in the for field, enter 3.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, in the Whenever this alarm drop-down list, select State is ALARM.
13. In the Send notification to drop-down list, select an existing Amazon SNS topic or create a new
one.
14. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
myHighCpuAlarm, and in the Email list field, enter a comma-separated list of email addresses to
be notified when the alarm changes to the ALARM state.
85
Amazon CloudWatch User Guide
Command Line Tools
15. In the navigation pane, click Create Alarm to complete the alarm creation process.
Command Line Tools
To send an Amazon Simple Notification Service email message when LoadBalancer
Latency Exceeds 100 Seconds
1. Create an Amazon Simple Notification Service topic. See instructions for creating an Amazon SNS
topic in Set Up Amazon Simple Notification Service (p. 78)
2. Create the alarm.
Prompt>aws cloudwatch put-metric-alarm --alarm-name lb-mon --
alarm-description "Alarm when Latency exceeds 100s" --metric-name
Latency --namespace AWS/ELB --statistic Average --period 60 --
threshold 100 --comparison-operator GreaterThanThreshold --dimensions
Name=LoadBalancerName,Value=my-server --evaluation-periods 3 --alarm-
actions arn:aws:sns:us-east-1:1234567890:my-topic --unit Seconds
The AWS CLI returns to the command prompt if the command succeeds.
3. Test the alarm.
Force an alarm state change to ALARM:
Prompt>aws cloudwatch set-alarm-state --alarm-name lb-mon --state-reason
"initializing" --state-value OK
Prompt>aws cloudwatch set-alarm-state --alarm-name lb-mon --state-reason
"initializing" --state-value ALARM
The AWS CLI returns to the command prompt if the command succeeds.
Check that you have received an email notification about the alarm.
Send Email Based on Storage Throughput
Alarm
This scenario walks you through how to use the AWS Management Console or the command line tools
to set up an Amazon Simple Notification Service notification and to configure an alarm that sends email
when EBS exceeds 100 MB throughput.
Topics
AWS Management Console (p. 86)
Command Line Tools (p. 88)
AWS Management Console
To create a storage throughput alarm that sends email
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
86
Amazon CloudWatch User Guide
AWS Management Console
2. If necessary, change the region. From the navigation bar, select the region that meets your needs.
For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in the CloudWatch Metrics by Category pane, select a metric
category, for example, EBS Metrics.
5. In the list of metrics, select a row that contains VolumeWriteBytes for a specific VolumeId.
A graph showing average VolumeWriteBytes for a single volume appears in the lower pane.
6. Select Average from the Statistic drop-down list.
7. Select 5 Minutes from the Period drop-down list.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: myHighWriteAlarm.
9. In the Description field, enter a description of the alarm, for example: VolumeWriteBytes
exceeds 100,000 KiB/s.
10. In the is drop-down list, select >.
11. In the box next to the is drop-down list, enter 100000 and in the for field, enter 15.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, in the Whenever this alarm drop-down list, select State is ALARM.
13. In the Send notification to drop-down list, select an existing Amazon SNS topic or create a new
one.
14. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
myHighCpuAlarm, and in the Email list field, enter a comma-separated list of email addresses to
be notified when the alarm changes to the ALARM state.
87
Amazon CloudWatch User Guide
Command Line Tools
15. In the navigation pane, click Create Alarm to complete the alarm creation process.
Command Line Tools
To send an Amazon Simple Notification Service email message when EBS exceeds 100
MB throughput
1. Create an Amazon Simple Notification Service topic. See instructions for creating an Amazon SNS
topic in Set Up Amazon Simple Notification Service (p. 78).
2. Create the alarm.
Prompt>aws cloudwatch put-metric-alarm --alarm-name ebs-mon --alarm-
description "Alarm when EBS volume exceeds 100MB throughput" --metric-
name VolumeReadBytes --namespace AWS/EBS --statistic Average --period
300 --threshold 100000000 --comparison-operator GreaterThanThreshold
--dimensions Name=VolumeId,Value=my-volume-id --evaluation-periods
3 --alarm-actions arn:aws:sns:us-east-1:1234567890:my-alarm-topic
--insufficient-data-actions arn:aws:sns:us-east-1:1234567890:my-
insufficient-data-topic
The AWS CLI returns to the command prompt if the command succeeds.
3. Test the alarm.
Force an alarm state change to ALARM.
Prompt>aws cloudwatch set-alarm-state --alarm-name lb-mon --state-reason
"initializing" --state-value OK
Prompt>aws cloudwatch set-alarm-state --alarm-name lb-mon --state-reason
"initializing" --state-value ALARM
Prompt>aws cloudwatch set-alarm-state --alarm-name lb-mon --state-reason
"initializing" --state-value INSUFFICIENT_DATA
Check that you have received two email notifications about the alarm.
Create Alarms That Stop, Terminate, Reboot,
or Recover an Instance
Using Amazon CloudWatch alarm actions, you can create alarms that automatically stop, terminate,
reboot, or recover your Amazon Elastic Compute Cloud (Amazon EC2) instances. You can use the
stop or terminate actions to help you save money when you no longer need an instance to be running.
You can use the reboot and recover actions to automatically reboot those instances or recover them
onto new hardware if a system impairment occurs.
Every alarm action you create uses alarm action ARNs. One set of ARNs is more secure because it
requires you to have the EC2ActionsAccess IAM role in your account. This IAM role enables you to
perform stop, terminate, or reboot actions--previously you could not execute an action if you were using
an IAM role. Existing alarms that use the previous alarm action ARNs do not require this IAM role,
however it is recommended that you change the ARN and add the role when you edit an existing alarm
that uses these ARNs.
88
Amazon CloudWatch User Guide
Create Alarms That Stop, Terminate,
Reboot, or Recover an Instance
The EC2ActionsAccess IAM role enables AWS to perform alarm actions on your behalf. When you
create an alarm action for the first time using the Amazon EC2 or Amazon CloudWatch consoles, AWS
automatically creates this role for you.
There are a number of scenarios in which you might want to automatically stop or terminate your
instance. For example, you might have instances dedicated to batch payroll processing jobs or
scientific computing tasks that run for a period of time and then complete their work. Rather than letting
those instances sit idle (and accrue charges), you can stop or terminate them which can help you
to save money. The main difference between using the stop and the terminate alarm actions is that
you can easily restart a stopped instance if you need to run it again later, and you can keep the same
instance ID and root volume. However, you cannot restart a terminated instance. Instead, you must
launch a new instance.
You can add the stop, terminate, reboot, or recover actions to any alarm that is set on an Amazon EC2
per-instance metric, including basic and detailed monitoring metrics provided by Amazon CloudWatch
(in the AWS/EC2 namespace), as well as any custom metrics that include the "InstanceId=" dimension,
as long as the InstanceId value refers to a valid running Amazon EC2 instance.
Permissions
If you are using an AWS Identity and Access Management (IAM) account to create or modify an alarm,
you must have the following permissions:
ec2:DescribeInstanceStatus and ec2:DescribeInstances — For all alarms on Amazon
EC2 instance status metrics
ec2:StopInstances — For alarms with stop actions
ec2:TerminateInstances — For alarms with terminate actions
ec2:DescribeInstanceRecoveryAttribute and ec2:RecoverInstances — For alarms with
recover actions
If you have read/write permissions for Amazon CloudWatch but not for Amazon EC2, you can still
create an alarm but the stop or terminate actions won't be performed on the instance. However, if you
are later granted permission to use the associated Amazon EC2 APIs, the alarm actions you created
earlier will be performed. For more information, see see Permissions and Policies in the IAM User
Guide.
If you want to use an IAM role to stop, terminate, or reboot an instance using an alarm action, you can
only use the EC2ActionsAccess role. Other IAM roles are not supported. If you are using another IAM
role, you cannot stop, terminate, or reboot the instance. However, you can still see the alarm state and
perform any other actions such as Amazon SNS notifications or Auto Scaling policies.
If you are using temporary security credentials granted using the AWS Security Token Service (AWS
STS), you cannot recover an Amazon EC2 instance using alarm actions.
Contents
Adding Stop Actions to Amazon CloudWatch Alarms (p. 90)
Adding Terminate Actions to Amazon CloudWatch Alarms (p. 91)
Adding Reboot Actions to Amazon CloudWatch Alarms (p. 93)
Adding Recover Actions to Amazon CloudWatch Alarms (p. 95)
Using the Amazon CloudWatch Console to View the History of Triggered Alarms and
Actions (p. 97)
Amazon CloudWatch Alarm Action Scenarios (p. 97)
89
Amazon CloudWatch User Guide
Adding Stop Actions to Amazon CloudWatch Alarms
Adding Stop Actions to Amazon CloudWatch
Alarms
You can configure the stop alarm action using the Amazon EC2 console or the Amazon CloudWatch
console. You can create an alarm that stops an Amazon EC2 instance when a certain threshold has
been met. For example, you may run development or test instances and occasionally forget to shut
them off. You can create an alarm that is triggered when the average CPU utilization percentage has
been lower than 10 percent for 24 hours, signaling that it is idle and no longer in use. You can adjust
the threshold, duration, and period to suit your needs, plus you can add an Amazon Simple Notification
Service (Amazon SNS) notification, so that you will receive an email when the alarm is triggered.
Amazon EC2 instances that use an Amazon Elastic Block Store volume as the root device can be
stopped or terminated, whereas instances that use the instance store as the root device can only be
terminated.
To create an alarm to stop an idle instance using the Amazon EC2 console
1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, under INSTANCES, click Instances.
4. In the contents pane, right-click an instance, select CloudWatch Monitoring, and then click Add/
Edit Alarms.
Or, you can also select the instance, and then in the lower pane on the Monitoring tab, click
Create Alarm.
5. In the Alarm Details for dialog box, click Create Alarm.
6. If you want to receive an email when the alarm is triggered, in the Create Alarm for dialog box,
in the Send a notification to box, select an existing Amazon SNS topic, or click Create Topic to
create a new one.
If you create a new topic, in the Send a notification to box type a name for the topic, and then
in the With these recipients box, type the email addresses of the recipients (separated by
commas). Later, after you create the alarm, you will receive a subscription confirmation email that
you must accept before you will get email for this topic.
7. Select the Take the action check box, and then choose the Stop this instance radio button.
8. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
9. In the Whenever boxes, choose the statistic you want to use and then select the metric. In this
example, choose Average and CPU Utilization.
10. In the Is boxes, define the metric threshold. In this example, enter 10 percent.
11. In the For at least box, choose the sampling period for the alarm. In this example, enter 24
consecutive periods of one hour.
12. To change the name of the alarm, in the Name this alarm box, type a new name.
If you don't type a name for the alarm, Amazon CloudWatch will automatically create one for you.
Note
You can adjust the alarm configuration based on your own requirements before creating
the alarm, or you can edit them later. This includes the metric, threshold, duration, action,
and notification settings. However, after you create an alarm, you cannot edit its name
later.
90
Amazon CloudWatch User Guide
Adding Terminate Actions to
Amazon CloudWatch Alarms
13. Click Create Alarm.
To create an alarm to stop an idle instance using the Amazon CloudWatch console
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in CloudWatch Metrics by Category, under EC2 Metrics, select
Per-Instance Metrics.
5. In the list of metrics, select the instance and metric you want to create an alarm for. You can also
type an instance ID in the search box to go the instance that you want.
6. Select Average from the Statistic drop-down list.
7. Select a period from the Period drop-down list, for example: 1 Day.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: Stop EC2 instance.
9. In the Description field, enter a description of the alarm, for example: Stop EC2 instance
when CPU is idle for too long.
10. In the is drop-down list, select <.
11. In the box next to the is drop-down list, enter 10 and in the for field, enter 1440.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, click EC2 Action.
13. In the Whenever this alarm drop-down list, select State is ALARM.
14. In the Take this action drop-down list, select Stop this instance.
15. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
16. Click Notification, and then in the Send notification to drop-down list, select an existing Amazon
SNS topic or create a new one.
17. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
Stop_EC2_Instance, and in the Email list field, enter a comma-separated list of email
addresses to be notified when the alarm changes to the ALARM state.
Important
If you are creating a new topic or adding email addresses to an existing topic, each
email address that you add will be sent a topic subscription confirmation email. You must
confirm the subscription by clicking the included link before notifications will be sent to a
new email address.
18. In the navigation pane, click Create Alarm to complete the alarm creation process.
Adding Terminate Actions to Amazon
CloudWatch Alarms
You can configure the terminate alarm action using the Amazon EC2 console or the Amazon
CloudWatch console. You can create an alarm that terminates an EC2 instance automatically when a
certain threshold has been met (as long as termination protection is not enabled for the instance). For
91
Amazon CloudWatch User Guide
Adding Terminate Actions to
Amazon CloudWatch Alarms
example, you might want to terminate an instance when it has completed its work, and you don't need
the instance again. If you might want to use the instance later, you should stop the instance instead of
terminating it. For information about enabling and disabling termination protection for an instance, see
Enabling Termination Protection for an Instance in the Amazon EC2 User Guide for Linux Instances.
To create an alarm to terminate an idle instance using the Amazon EC2 console
1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, under INSTANCES, click Instances.
4. In the upper pane, right-click an instance, select CloudWatch Monitoring, and then click Add/
Edit Alarms.
Or, select the instance and then in the lower pane, on the Monitoring tab, click Create Alarm.
5. In the Alarm Details for dialog box, click Create Alarm.
6. If you want to receive an email when the alarm is triggered, in the Create Alarm for dialog box,
in the Send a notification to box, select an existing Amazon SNS topic, or click Create Topic to
create a new one.
If you create a new topic, in the Send a notification to box type a name for the topic, and then
in the With these recipients box, type the email addresses of the recipients (separated by
commas). Later, after you create the alarm, you will receive a subscription confirmation email that
you must accept before you will get email for this topic.
7. Select the Take the action check box, and then choose the Terminate this instance radio
button.
8. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
9. In the Whenever boxes, choose the statistic you want to use and then select the metric. In this
example, choose Average and CPU Utilization.
10. In the Is boxes, define the metric threshold. In this example, enter 10 percent.
11. In the For at least box, choose the sampling period for the alarm. In this example, enter 24
consecutive periods of one hour.
12. To change the name of the alarm, in the Name this alarm box, type a new name.
If you don't type a name for the alarm, Amazon CloudWatch will automatically create one for you.
Note
You can adjust the alarm configuration based on your own requirements before creating
the alarm, or you can edit them later. This includes the metric, threshold, duration, action,
and notification settings. However, after you create an alarm, you cannot edit its name
later.
13. Click Create Alarm.
To create an alarm to terminate an idle instance using the Amazon CloudWatch console
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in CloudWatch Metrics by Category, under EC2 Metrics, select
Per-Instance Metrics.
92
Amazon CloudWatch User Guide
Adding Reboot Actions to
Amazon CloudWatch Alarms
5. In the list of metrics, select the instance and metric you want to create an alarm for. You can also
type an instance ID in the search box to go the instance that you want.
6. Select Average from the Statistic drop-down list.
7. Select a period from the Period drop-down list, for example: 1 Day.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: Terminate EC2 instance.
9. In the Description field, enter a description of the alarm, for example: Terminate EC2
instance when CPU is idle for too long.
10. In the is drop-down list, select <.
11. In the box next to the is drop-down list, enter 10 and in the for field, enter 1440.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, click EC2 Action.
13. In the Whenever this alarm drop-down list, select State is ALARM.
14. In the Take this action drop-down list, select Terminate this instance.
15. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
16. Click Notification, and then in the Send notification to drop-down list, select an existing Amazon
SNS topic or create a new one.
17. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
Terminate_EC2_Instance, and in the Email list field, enter a comma-separated list of email
addresses to be notified when the alarm changes to the ALARM state.
Important
If you are creating a new topic or adding email addresses to an existing topic, each
email address that you add will be sent a topic subscription confirmation email. You must
confirm the subscription by clicking the included link before notifications will be sent to a
new email address.
18. In the navigation pane, click Create Alarm to complete the alarm creation process.
Adding Reboot Actions to Amazon CloudWatch
Alarms
You can create an Amazon CloudWatch alarm that monitors an Amazon EC2 instance and
automatically reboots the instance. The reboot alarm action is recommended for Instance Health
Check failures (as opposed to the recover alarm action, which is suited for System Health Check
failures). An instance reboot is equivalent to an operating system reboot. In most cases, it takes only
a few minutes to reboot your instance. When you reboot an instance, it remains on the same physical
host, so your instance keeps its public DNS name, private IP address, and any data on its instance
store volumes.
Rebooting an instance doesn't start a new instance billing hour, unlike stopping and restarting your
instance. For more information about rebooting an instance, see Reboot Your Instance in the Amazon
EC2 User Guide for Linux Instances.
Important
To avoid a race condition between the reboot and recover actions, we recommend that you
set the alarm threshold to 3 for 1 minute when creating alarms that reboot an Amazon EC2
instance.
93
Amazon CloudWatch User Guide
Adding Reboot Actions to
Amazon CloudWatch Alarms
To create an alarm to reboot an instance using the Amazon EC2 console
1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, under INSTANCES, click Instances.
4. In the upper pane, right-click an instance, select CloudWatch Monitoring, and then click Add/
Edit Alarms.
Or, select the instance and then in the lower pane, on the Monitoring tab, click Create Alarm.
5. In the Alarm Details for dialog box, click Create Alarm.
6. If you want to receive an email when the alarm is triggered, in the Create Alarm for dialog box,
in the Send a notification to box, select an existing Amazon SNS topic, or click Create Topic to
create a new one.
If you create a new topic, in the Send a notification to box type a name for the topic, and then
in the With these recipients box, type the email addresses of the recipients (separated by
commas). Later, after you create the alarm, you will receive a subscription confirmation email that
you must accept before you will get email for this topic.
7. Select the Take the action check box, and then choose the Reboot this instance radio button.
8. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
9. In the Whenever box, choose Status Check Failed (Instance).
10. In the For at least field, enter 3.
11. In the consecutive period(s) of box, select 1 minute.
12. To change the name of the alarm, in the Name of alarm box, type a new name.
If you don't type a name for the alarm, Amazon CloudWatch will automatically create one for you.
13. Click Create Alarm.
To create an alarm to reboot an instance using the Amazon CloudWatch console
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in CloudWatch Metrics by Category, under EC2 Metrics, select
Per-Instance Metrics.
5. In the list of metrics, select the instance and StatusCheckFailed_Instance metric you want to
create an alarm for. You can also type an instance ID in the search box to go the instance that you
want.
6. Select Minimum from the Statistic drop-down list.
Note
This is the only statistic that is currently supported.
7. Select a period from the Period drop-down list, for example: 1 Minute.
8. Click Next, and then under Alarm Threshold, in the Name field, enter a unique name for the
alarm, for example: Reboot EC2 instance.
9. In the Description field, enter a description of the alarm, for example: Reboot EC2 instance
when health checks fail.
94
Amazon CloudWatch User Guide
Adding Recover Actions to
Amazon CloudWatch Alarms
10. In the is drop-down list, select >.
11. In the box next to the is drop-down list, enter 0 and in the for field, enter 3.
A graphical representation of the threshold is shown under Alarm Preview.
12. Under Actions, click EC2 Action.
13. In the Whenever this alarm drop-down list, select State is ALARM.
14. In the Take this action drop-down list, select Reboot this instance.
15. Click Notification, and then in the Send notification to drop-down list, select an existing Amazon
SNS topic or create a new one.
16. To create a new Amazon SNS topic, select New list.
In the Send notification to field, enter a name for the new Amazon SNS topic for example:
Reboot_EC2_Instance, and in the Email list field, enter a comma-separated list of email
addresses to be notified when the alarm changes to the ALARM state.
Important
If you are creating a new topic or adding email addresses to an existing topic, each
email address that you add will be sent a topic subscription confirmation email. You must
confirm the subscription by clicking the included link before notifications will be sent to a
new email address.
17. In the navigation pane, click Create Alarm to complete the alarm creation process.
Adding Recover Actions to Amazon CloudWatch
Alarms
You can create an Amazon CloudWatch alarm that monitors an Amazon EC2 instance and
automatically recovers the instance if it becomes impaired due to an underlying hardware failure or
a problem that requires AWS involvement to repair. Terminated instances cannot be recovered. A
recovered instance is identical to the original instance, including the instance ID, private IP addresses,
Elastic IP addresses, and all instance metadata.
When the StatusCheckFailed_System alarm is triggered, and the recover action is initiated, you
will be notified by the Amazon SNS topic that you selected when you created the alarm and associated
the recover action. During instance recovery, the instance is migrated during an instance reboot, and
any data that is in-memory is lost. When the process is complete, information is published to the SNS
topic you've configured for the alarm. Anyone who is subscribed to this SNS topic will receive an email
notification that includes the status of the recovery attempt and any further instructions. You will notice
an instance reboot on the recovered instance.
Examples of problems that cause system status checks to fail include:
Loss of network connectivity
Loss of system power
Software issues on the physical host
Hardware issues on the physical host
The recover action is only supported on:
The C3, C4, M3, M4, R3, T2, and X1 instance types
Instances in a VPC
Instances with shared tenancy (the tenancy attribute is set to default)
95
Amazon CloudWatch User Guide
Adding Recover Actions to
Amazon CloudWatch Alarms
Instances that use Amazon EBS storage exclusively
If your instance has a public IP address, it will retain the same public IP address after recovery.
Important
To avoid a race condition between the reboot and recover actions, we recommend that you
set the alarm threshold to 2 for 1 minute when creating alarms that recover an Amazon EC2
instance.
To create an alarm to recover an instance using the Amazon EC2 console
1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, under INSTANCES, click Instances.
4. In the upper pane, right-click an instance, select CloudWatch Monitoring, and then click Add/
Edit Alarms.
Or, select the instance and then in the lower pane, on the Monitoring tab, click Create Alarm.
5. In the Alarm Details for dialog box, click Create Alarm.
6. If you want to receive an email when the alarm is triggered, in the Create Alarm for dialog box,
in the Send a notification to box, select an existing Amazon SNS topic, or click Create Topic to
create a new one.
If you create a new topic, in the Send a notification to box type a name for the topic, and then
in the With these recipients box, type the email addresses of the recipients (separated by
commas). Later, after you create the alarm, you will receive a subscription confirmation email that
you must accept before you will get email for this topic.
7. Select the Take the action check box, and then choose the Recover this instance radio button.
8. If prompted, select the Create IAM role: EC2ActionsAccess check box to automatically create
an IAM role so that AWS can automatically stop the instance on your behalf when the alarm is
triggered.
9. In the Whenever box, choose Status Check Failed (System).
10. In the For at least field, enter 2.
11. In the consecutive period(s) of box, select 1 minute.
12. To change the name of the alarm, in the Name of alarm box, type a new name.
If you don't type a name for the alarm, Amazon CloudWatch will automatically create one for you.
13. Click Create Alarm.
To create an alarm to recover an instance using the Amazon CloudWatch console
1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
2. If necessary, change the region. From the navigation bar, select the region where your instance is
running. For more information, see Regions and Endpoints.
3. In the navigation pane, click Alarms.
4. Click Create Alarm, and then in CloudWatch Metrics by Category, under EC2 Metrics, select
Per-Instance Metrics.
5. In the list of metrics, select the instance and StatusCheckFailed_System metric you want to
create an alarm for. You can also type an instance ID in the search box to go the instance that you
want.
6. Select Minimum from the Statistic drop-down list.
96