You are on page 1of 78

Amazon CloudWatch

Developer Guide
API Version 2009-05-15
Amazon CloudWatch Developer Guide

Amazon CloudWatch: Developer Guide


Copyright © 2009 Amazon Web Services LLC or its affiliates. All rights reserved.
Amazon CloudWatch Developer Guide

Table of Contents
Welcome ............................................................................................................................................................ 1
What's New ....................................................................................................................................................... 4
Introduction to Amazon CloudWatch ................................................................................................................ 5
Using Amazon CloudWatch ............................................................................................................................ 14
Getting Started with Amazon CloudWatch .......................................................................................... 16
Using the Query API ........................................................................................................................... 19
Using the SOAP API ........................................................................................................................... 22
Metrics ................................................................................................................................................. 26
Statistics .............................................................................................................................................. 28
About Dimensions ............................................................................................................................... 29
Amazon CloudWatch Dimensions ....................................................................................................... 31
User Scenarios .................................................................................................................................... 32
Get Average CPUUtilization for EC2 Instances With a Particular ImageId ................................ 33
Get Maximum CPUUtilization per EC2 Instance ....................................................................... 35
Compare RequestCount by Availability Zone for a Load Balanced EC2 Application ................. 37
Get Latency Statistics for a LoadBalancer ................................................................................ 39
Get Total DiskWriteBytes for a Capacity-Managed EC2 Application ......................................... 41
Get A Single Metric Across All Dimensions .............................................................................. 43
Get Available Metrics Across Multiple Instances ....................................................................... 45
API Reference ................................................................................................................................................. 47
API Conventions .................................................................................................................................. 47
Common Request Parameters ............................................................................................................ 49
Error Codes ......................................................................................................................................... 50
Amazon CloudWatch Operations ........................................................................................................ 54
GetMetricStatistics ...................................................................................................................... 55
ListMetrics .................................................................................................................................. 60
Data Types .......................................................................................................................................... 62
Datapoint .................................................................................................................................... 63
Datapoints .................................................................................................................................. 64
Dimension .................................................................................................................................. 65
Dimensions ................................................................................................................................. 66
StandardUnit ............................................................................................................................... 67
Statistics ..................................................................................................................................... 68
Glossary .......................................................................................................................................................... 69
Document Conventions ................................................................................................................................... 71
Index ................................................................................................................................................................ 74
Amazon CloudWatch Developer Guide
Who Should Read This Guide

Welcome

Topics
• Who Should Read This Guide (p. 1)
• How This Guide Is Organized (p. 2)
• Amazon CloudWatch Resources (p. 2)

Amazon CloudWatch is an easy-to-use web service that provides comprehensive monitoring for
Amazon Elastic Compute Cloud (Amazon EC2) and Elastic Load Balancing.

This is the Amazon CloudWatch Developer Guide. This section describes who should read this guide,
how the guide is organized, and other resources related to Amazon CloudWatch.

The following Amazon Web Services (AWS) products will occasionally be referred to using the
following abbreviated forms; all copyrights and legal protections still apply.

Full Name Abbreviated Form

Amazon Elastic Compute Amazon EC2


Cloud

Amazon Machine Image AMI

Who Should Read This Guide


This guide is intended for developers, as well as those in IT/Operations, who are building web
applications or services hosted in the Amazon Elastic Compute Cloud.

Required Knowledge and Skills


Use of this guide assumes you are familiar with the following:

• XML. For an overview, go to the W3 Schools XML Tutorial.


• Web services. For an overview, go to the W3 Schools Web Services Tutorial.

API Version 2009-05-15


1
Amazon CloudWatch Developer Guide
How This Guide Is Organized

• A programming language for consuming a web service and any related tools.
• Programming Amazon Elastic Cloud Computing (EC2) applications or services that use Amazon
EC2 web service APIs. For information about Amazon EC2, go to the Amazon EC2 product
information page.

How This Guide Is Organized


This guide is organized into several major sections described in the table below.

Information Relevant Sections

General information about Amazon What is Amazon CloudWatch? (p. 6)


CloudWatch

Conceptual information about Amazon • Conceptual Overview of Amazon CloudWatch (p. 10)
CloudWatch • Terminology and Key Concepts (p. 7)

API Reference and Programming • API Reference (p. 47)


Related Information • Using Amazon CloudWatch (p. 14)

Typographic and symbol conventions Document Conventions (p. 71)

There are more sections under each category to help you with more specific information as well as a
glossary and an index. Most sections are written to stand on their own with some cross dependencies.
You should, in general, be able to look up the information you need and go back to work. However, you
can also read through the major sections sequentially to get in-depth knowledge about the service.

Amazon CloudWatch Resources


The table below lists related resources that you'll find useful as you work with this service.

Resource Description

Amazon CloudWatch Technical FAQ The FAQ covers the top 20 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.

Discussion Forums A community-based forum for developers to discuss


technical questions related to Amazon Web Services.

AWS Support Center The home page for AWS Technical Support, including
access to our Developer Forums, Technical FAQs, Service
Status page, and Premium Support.

API Version 2009-05-15


2
Amazon CloudWatch Developer Guide
Amazon CloudWatch Resources

Resource Description

AWS Premium Support The primary web page for information about AWS Premium
Support, a one-on-one, fast-response support channel to
help you build and run applications on AWS Infrastructure
Services.

Amazon CloudWatch product The primary web page for information about Amazon
information CloudWatch.

Contact Us A central contact point for inquiries concerning AWS billing,


account, events, abuse etc.

Conditions of Use Detailed information about the copyright and trademark


usage at Amazon.com and other topics.

API Version 2009-05-15


3
Amazon CloudWatch Developer Guide

What's New

This What's New is associated with the 2009-05-15 release of Amazon CloudWatch. This guide was
last updated on December 09, 2009.

The following table describes the important changes since the last release of the Amazon CloudWatch
Developer Guide.

Change Description Release Date

Updated/added Added new US-West (Northern California) Region 02 December 2009


content information.

Added content Added information about .NET SDK support. For 11 November 2009
more information, see Programming Language
Support (p. 22).

Added/updated Bug fixes; added new Region information. 14 September 2009


content

Added content Added instructions on how to enable monitoring 31 August 2009


using the AWS Management Console to the Getting
Started (p. 16) section.

Updated content Bug fixes. 21 July 2009

Added content Instructions for Command Line Tools have been 28 May 2009
added to the User Scenarios (p. 32) section.

New Service This is the first release of Amazon CloudWatch 18 May 2009
Developer Guide. Future updates and changes will
be noted here.

API Version 2009-05-15


4
Amazon CloudWatch Developer Guide

Introduction to Amazon
CloudWatch

Topics
• What Is Amazon CloudWatch? (p. 6)
• Amazon CloudWatch Concepts (p. 7)
• Amazon CloudWatch Conceptual Overview (p. 10)

This introduction is intended to give you a detailed summary of this set of web services. After reading
this section, you should have a good idea of what they offer and how they can fit with your business
and application needs.

API Version 2009-05-15


5
Amazon CloudWatch Developer Guide
What Is Amazon CloudWatch?

What Is Amazon CloudWatch?


Amazon CloudWatch is an easy to use web service that provides visibility into your cloud assets. It is
designed to provide comprehensive monitoring for all of the following AWS services:

• Amazon Elastic Compute Cloud or Amazon EC2 (including instances of paid AMIs)
• Elastic Load Balancing

Benefits
• Visibility—Amazon CloudWatch enables visibility into all of your cloud assets. You receive
comprehensive operational views of all AWS services.
• Ease of Use—Amazon CloudWatch uses a simple API call for developers. There is no upfront setup
in order to start getting the metrics.

API Version 2009-05-15


6
Amazon CloudWatch Developer Guide
Amazon CloudWatch Concepts

Amazon CloudWatch Concepts


This section introduces you to Amazon CloudWatch terminology and concepts. Many of the concepts
introduced here are discussed in more specific contexts in later sections. The concepts are briefly
presented here to give you a basic understanding of common Amazon CloudWatch terms.

Dimension
A dimension is used by the developer to specify how a measure will be aggregated, such as by
InstanceID, Availability Zone, or AutoScalingGroup. If you do not specify a dimension name or value,
then all data for a particular measure and timespan will be aggregated into a single metric.

For more information, see About Dimensions (p. 29). For a list of currently available dimensions,
please see Amazon CloudWatch Dimensions (p. 31).

Measure
A measure is an observed value with a name, a set of dimensions, a namespace, a unit, and a
timestamp. Measures are the fundamental input to the Amazon CloudWatch. Measures are the raw
data that goes into the system and that are rolled up (aggregated) into bigger chunks called metrics.
Measures have the following attributes:

• Measures have a unique name


• Measures might have one or more dimensions
• Measures can arrive at any time, in any order, with the same resulting metrics
• The service that the measure is recorded from is identified by the namespace

Measures have the following characteristics:

• If multiple measures with the same name and dimensions have the same measure values within the
same one-minute period, they will be rolled up into one-minute aggregations
• All incoming measurements for any time slot are buffered for one-minute to perform aggregation
processing before they can be read
• Measures are retained by Amazon CloudWatch for a period of two weeks

Metric
A metric is an aggregation of raw measure data that was published to Amazon CloudWatch,
aggregated by a particular unit of measure, such as bytes or seconds. Metrics are the fundamental
stored elements in the Amazon CloudWatch system.

Metrics have the following attributes:

• A metric has a measure name that comes from or is derived from the input measures
• A metric may have additional dimensions to make it more specific, e.g. InstanceID="i-a123b4cd"
• Every metric has a unique set of matching criteria and a namespace

Namespace
Namespaces provide isolation within the Amazon CloudWatch system for metrics that were generated
by different sources. All AWS services that provide Amazon CloudWatch data use a namespace string
beginning with “AWS/”.

API Version 2009-05-15


7
Amazon CloudWatch Developer Guide
Statistic

For example, all EC2 metrics are published using the Namespace “AWS/EC2”. This ensures that
customers who request data associated with the namespace “AWS/EC2” only get back results from
measures that were stored by EC2.

At present, there are two AWS services that store data in Amazon CloudWatch: Amazon Elastic
Compute Cloud (EC2) and Elastic Load Balancing (ELB).

• To request metrics from Amazon EC2, set the Namespace in your GetMetricStatistics call to
AWS/EC2. For an example, see GetMetricStatistics (p. 55).
• To request metrics from Elastic Load Balancing (ELB), set the Namespace in your
GetMetricStatistics call to AWS/ELB. For a sample request, refer to the Elastic Load Balancing
Developer Guide.

Statistic
Statistics are attributes of a metric. They describe the distribution of measures that created each
Amazon CloudWatch metric.

Statistics can be used in the following ways:

• There following statistics are available: Minimum, Maximum, Sum and Average.

Note

Another statistic - Samples - is the count of the measurements that were used to compute a
return value. The Samples statistics is always returned and cannot be explicitly requested.

For example, if the values that are aggregated into a single metric are [1, 2, 5], then the statistics
would be the following: Samples = 3, Average = 4, Minimum = 1, Maximum = 5, and Sum = 8.

Please see Amazon CloudWatch Statistics Available (p. 28) for more information
• A statistic has only one value per one-minute period.
• A query using GetMetricStatistics (p. 55) specifies a finite period which aggregates all the
enclosed one-minute time slots that have a value. This is known as time aggregation.

Unit
Every measure that is received by the system has a unit attached, such as seconds or bytes.

Units have the following characteristics:

• For a complete list of currently supported standard units, see StandardUnit (p. 67).
• The Units parameter is a filter for the GetMetricStatistics (p. 55) call. If you don't specify it, you
get all the units that were used for the measure data when the data was put into the system. If you
do specify it, you get values that match your request. Specifying the units incorrectly can result in no
data being returned.

Regions
Amazon cloud computing resources are housed in highly available data center facilities. To provide
additional scalability and reliability, these data center facilities are located in several different physical
locations, known as Regions. Regions are large and widely dispersed geographic locations.
API Version 2009-05-15
8
Amazon CloudWatch Developer Guide
Regions

Note

Amazon CloudWatch does not aggregate data across Regions. Metrics are completely
separate between Regions.

To work with instances in a specific Region, use the corresponding regional service endpoint.
In the United States, the endpoints are:

• US Standard Region: https://monitoring.us-east-1.amazonaws.com


• US-West (Northern California) Region: https://monitoring.us-west-1.amazonaws.com

In the EU (Ireland) Region, the endpoint is:

• https://monitoring.eu-west-1.amazonaws.com

If no endpoint is explicitly specified, the US Standard Region endpoint is used by default.

API Version 2009-05-15


9
Amazon CloudWatch Developer Guide
Amazon CloudWatch Conceptual Overview

Amazon CloudWatch Conceptual Overview


Amazon CloudWatch collects raw data from AWS services such as Amazon Elastic Compute Cloud
(EC2) and then processes the information into readable metrics. These metrics are recorded for a
period of two weeks, allowing you to access historical information and providing you with a better
perspective on how your web application or service is performing.

Note

Amazon cloud computing resources can be physically located in one of several Regions.
Amazon CloudWatch does not aggregate data across Regions.

The basic concept of the service is outlined in the following illustration. Amazon CloudWatch captures
the raw data from the AWS service and creates metrics.

The raw, collected data gathered by Amazon Cloudwatch is known as a measure. A measure might be
something like CPUUtilization for a given EC2 instance, which is the percentage of EC2 compute units
the instance is using, or DiskWriteBytes, which is just the number of bytes that have been written.

A measure is comprised of its name, such as DiskWriteBytes, and its value, such as 0. Measures also
usually have a unit, such as Bytes. Measures also include a timestamp indicating when the data was
recorded. Measures may include other attributes, called dimensions, which provide further context if
present.

API Version 2009-05-15


10
Amazon CloudWatch Developer Guide
Amazon CloudWatch Conceptual Overview

The following information is part of the measure as it enters the Amazon CloudWatch system for
processing:

• the measure's name (e.g. DiskWriteBytes)


• the unprocessed value (e.g. 20)
• the associated dimensions of this measure (e.g. InstanceType, InstanceId)
• a unit to determine the type of value (e.g. Bytes)
• a namespace to identify the service from which the measure was recorded (e.g. AWS/EC2)

Each of the blue boxes in the following illustration is a single measure from a single EC2 instance.

These measures have two dimensions:

• InstanceId—The name of the instance that generated the metric instance type
• InstanceType—The type of instance specified by the InstanceId (e.g. m1.small)

All of this information taken together makes the metric unique.

API Version 2009-05-15


11
Amazon CloudWatch Developer Guide
Amazon CloudWatch Conceptual Overview

Processed data is called a metric. It has the same name, dimensions, namespace, and unit as the
original measures used to create the metric. A metric is the aggregate of all of the measures that are
published to the system with a given name, within a single one-minute period. When you ask for data
from Amazon CloudWatch, you are asking for metric data.

As Amazon CloudWatch processes measure data, the service rolls the incoming data into one-minute
chunks. Therefore, if ten measures come in during a particular one-minute time slot, then ten measures
will be turned into a single chunk with statistics are that calculated to give different views of the data
such as Average, Sum, Minimum, or Maximum.

In the following illustration, Amazon CloudWatch captures a set of 12 measures with two unique names
and processes them into two metrics.

You can query metric data using measure names, dimensions, and units for a specified measure of
time. For example, requesting the CPUUtilization data across all of your m1.small instance types for
a span of 10 minutes would return the measures for all instances, rolled up into a single metric. This
metric would be an aggregation of the one-minute chunks of data over the time span you requested,
filtered by the other attributes you specified in your query.

API Version 2009-05-15


12
Amazon CloudWatch Developer Guide
Amazon CloudWatch Conceptual Overview

In the following example, a developer is monitoring the health of his application, and requests several
metrics to determine the future needs of his business. He requests the Minimum, Maximum, and
Average statistics of the CPUUtilization metric.

Using this information, the developer can adjust his services directly according to the needs of his
business.

Using the RequestCount metrics represented by the green boxes in the following illustration, the
developer can verify the number of requests sent to his application. Using the Maximum statistic of
the CPUUtilization metrics, represented by the purple boxes surrounded in red, the developer can
check how stressed his application is during high volume periods. Using the Average statistic of the
CPUUtilization metrics, represented by the orange metric boxes, the developer can find out how long
periods of high system stress last.

Amazon CloudWatch provides the data you need to make informed decisions. You specify the metric
you want and you receive statistics for that metric. This allows you to build complex queries in order to
access different views of the data, for periods of one-minute up to two weeks in length.

For more information about Amazon CloudWatch, please see the Using Amazon CloudWatch (p.
14) and the API Reference (p. 47).

API Version 2009-05-15


13
Amazon CloudWatch Developer Guide

Using Amazon CloudWatch

Topics
• Getting Started with Amazon CloudWatch (p. 16)
• Using the Query API (p. 19)
• Using the SOAP API (p. 22)
• Metrics (p. 26)
• Statistics (p. 28)
• About Dimensions (p. 29)
• Amazon CloudWatch Dimensions (p. 31)
• User Scenarios (p. 32)

This section provides task-oriented descriptions of how to use and implement Amazon CloudWatch
operations. For a complete description of Amazon CloudWatch operations, refer to the API
Reference (p. 47).

API Version 2009-05-15


14
Amazon CloudWatch Developer Guide

API Version 2009-05-15


15
Amazon CloudWatch Developer Guide
Getting Started with Amazon CloudWatch

Getting Started with Amazon CloudWatch


Getting started with using Amazon CloudWatch is easy. If you are signed up for the Amazon EC2
service, you are automatically registered for Amazon CloudWatch. You can activate Amazon
CloudWatch using the command line tools or the AWS Management Console.

Activating Amazon CloudWatch Using the AWS


Management Console
To activate Amazon CloudWatch using the console, follow the steps below.

1. Sign in to the AWS Management Console.


2. On the Amazon EC2 tab, click the Launch Instances button.
3. Select an AMI from the list to display the Launch Instance Wizard dialog and configure your EC2
instance.
4. On the last step of the Launch Instance Wizard, click the Enable CloudWatch monitoring for
this instance checkbox.
5. Click the Launch button.
6. Click the View your instances on the Instances page link to display a list of your instances. In a
few minutes, the status of the instance you just launched will change to Running.
7. Select the running instance and click on the Monitoring tab at the bottom of the list to access
graphs for CPU, disk, and network metrics.

Activating Amazon CloudWatch Using the


Command Line Tools
Follow the steps below to activate Amazon CloudWatch using the command line tools

1. Download the Command Line Tools from Amazon EC2 API tools Amazon EC2 API tools.
2. Use the ec2-monitor-instances command to enable monitoring for any running Amazon EC2
instance. If you want to launch Amazon EC2 instances with monitoring enabled, you can do so by
passing a monitoring parameter to the ec2-run-instances command.

Note

Instances spun up by Auto Scaling are automatically monitored by Amazon CloudWatch.


3. Use the mon-get-stats to view metrics for an Amazon EC2 instance or Elastic Load Balancer.

Command Line Tools Example


This section shows some examples of command line tools usage.

• Use the EC2 ec2-run-instances command as in the following example.

PROMPT>ec2-run-instances ami-60a54009 -n 3 --availability-zone us-east-1a

Note

If you wanted to automatically monitor all of the EC Instances spun up by the above
command, you would add --monitoring. This allows you to skip Step 2 in this procedure.

API Version 2009-05-15


16
Amazon CloudWatch Developer Guide
Command Line Tools Example

The command will return a unique identifier for each launched instance. You use the instance ID to
manipulate the instance. This includes viewing the status of the instance, terminating the instance,
and so on. Launching the instance will take a few minutes.

RESERVATION r-237fed4a 853279305796 default


INSTANCE i-d9add0b0 ami-60a54009 pending 0 m1.small 2009-05-14T12:38:24+0000
us-east-1a aki-a71cf9ce ari-a51cf9cc monitoring-disabled
• Use the mon-list-metrics command to get a list of what metrics are being stored for your AWS
account. For example:

PROMPT>mon-list-metrics

The mon-list-metrics outputs a table containing the Measure name, Namespace, and Dimension
associated with each metric. For example:

CPUUtilization AWS/EC2 {InstanceId=i-c385b3aa}


CPUUtilization AWS/EC2 {ImageId=ami-11ca2d78}
CPUUtilization AWS/EC2 {InstanceType=m1.small}
CPUUtilization AWS/EC2
DiskReadBytes AWS/EC2 {ImageId=ami-11ca2d78}
DiskReadBytes AWS/EC2 {InstanceType=m1.small}
DiskReadBytes AWS/EC2
DiskReadBytes AWS/EC2 {InstanceId=i-c385b3aa}
DiskReadOps AWS/EC2 {InstanceId=i-c385b3aa}
DiskReadOps AWS/EC2 {InstanceType=m1.small}
DiskReadOps AWS/EC2
DiskReadOps AWS/EC2 {ImageId=ami-11ca2d78}
DiskWriteBytes AWS/EC2 {InstanceId=i-c385b3aa}
DiskWriteBytes AWS/EC2 {InstanceType=m1.small}
DiskWriteBytes AWS/EC2 {ImageId=ami-11ca2d78}
DiskWriteBytes AWS/EC2
DiskWriteOps AWS/EC2 {InstanceId=i-c385b3aa}
DiskWriteOps AWS/EC2 {ImageId=ami-11ca2d78}
DiskWriteOps AWS/EC2 {InstanceType=m1.small}
DiskWriteOps AWS/EC2
NetworkIn AWS/EC2
NetworkIn AWS/EC2 {InstanceId=i-c385b3aa}
NetworkIn AWS/EC2 {ImageId=ami-11ca2d78}
NetworkIn AWS/EC2 {InstanceType=m1.small}
NetworkOut AWS/EC2 {InstanceType=m1.small}
NetworkOut AWS/EC2
NetworkOut AWS/EC2 {ImageId=ami-11ca2d78}
NetworkOut AWS/EC2 {InstanceId=i-c385b3aa}

• Use the EC2 ec2-monitor-instances command as in the following example.

PROMPT> ec2-monitor-instances i-43a4412a

ec2-monitor-instances returns a table that contains the selected instance IDs and the current
Monitoring state.

i-43a4412a monitoring-pending
• Use the Amazon CloudWatch mon-get-stats command as in the following example.

API Version 2009-05-15


17
Amazon CloudWatch Developer Guide
Command Line Tools Example

PROMPT> mon-get-stats CPUUtilization --start-time 2009-05-15T00:00:00 --end-


time 2009-05-16T00:00:00 --period 60 --statistics "Average"
--namespace "AWS/EC2" --dimensions "ImageId=ami-60a54009"

Amazon CloudWatch returns a response similar to the following (the data has been truncated for
brevity):

2009-05-15 22:42:00 6.0 0.38 Percent


2009-05-15 22:48:00 6.0 0.39 Percent
2009-05-15 22:54:00 6.0 0.38 Percent

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, CPUUtilization, and unit.

API Version 2009-05-15


18
Amazon CloudWatch Developer Guide
Using the Query API

Using the Query API


Query requests are HTTP or HTTPS requests that use the HTTP verb GET or POST and a Query
parameter named Action or Operation. Action is used throughout this documentation, although
Operation is supported for backward compatibility with other AWS Query APIs.

Query Parameters
Each Query request must include some common parameters to handle authentication and selection of
an action. For more information, see Common Request Parameters (p. 49).

Note

Some API operations take lists of parameters. These lists are specified using the following
notation: param.member.n. Values of n are integers starting from 1. All lists of parameters
must follow this notation, including lists that only contain one parameter. For example, a Query
parameter list looks like this:

&attribute.member.1=this
&attribute.member.2=that

The RequestId
In every response from Amazon Web Services (AWS), you will find ResponseMetadata, which
contains a string element called RequestId. This is simply a unique identifier AWS assigns to provide
tracking information. To improve readability of the API documentation and reduce redundancy,
whereas RequestId is included as part of every response, it will not be listed on the individual API
documentation pages.

Query API Authentication


You can send Query requests over either HTTP or HTTPS. Regardless of which protocol you use, you
must include a signature in every Query request. This section describes how to create the signature.
The method described in the following procedure is known as signature version 2.

To create the signature

1. Create the canonicalized query string that you need later in this procedure:

a. Sort the UTF-8 query string components by parameter name with natural byte ordering.
The parameters can come from the GET URI or from the POST body (when Content-Type
is application/x-www-form-urlencoded).
b. URL encode the parameter name and values according to the following rules:

• Do not URL encode any of the unreserved characters that RFC 3986 defines.
These unreserved characters are A-Z, a-z, 0-9, hyphen ( - ), underscore ( _ ), period ( . ),
and tilde ( ~ ).
• Percent encode all other characters with %XY, where X and Y are hex characters 0-9 and
uppercase A-F.
• Percent encode extended UTF-8 characters in the form %XY%ZA....
• Percent encode the space character as %20 (and not +, as common encoding schemes
do).

API Version 2009-05-15


19
Amazon CloudWatch Developer Guide
Query API Authentication

Note

Currently all AWS service parameter names use unreserved characters, so you don't
need to encode them. However, you might want to include code to handle parameter
names that use reserved characters, for possible future use.
c. Separate the encoded parameter names from their encoded values with the equals sign ( = )
(ASCII character 61), even if the parameter value is empty.
d. Separate the name-value pairs with an ampersand ( & ) (ASCII code 38).
2. Create the string to sign according to the following pseudo-grammar (the "\n" represents an
ASCII newline).

StringToSign = HTTPVerb + "\n" +


ValueOfHostHeaderInLowercase + "\n" +
HTTPRequestURI + "\n" +
CanonicalizedQueryString <from the preceding step>

The HTTPRequestURI component is the HTTP absolute path component of the URI up to, but not
including, the query string. If the HTTPRequestURI is empty, use a forward slash ( / ).
3. Calculate an RFC 2104-compliant HMAC with the string you just created, your Secret Access
Key (p. 70) as the key, and SHA256 or SHA1 as the hash algorithm.
For more information, go to http://www.ietf.org/rfc/rfc2104.txt.
4. Convert the resulting value to base64.
5. Use the resulting value as the value of the Signature request parameter.

Important

The final signature you send in the request must be URL encoded as specified in RFC 3986
(for more information, go to http://www.ietf.org/rfc/rfc3986.txt). If your toolkit URL encodes
your final request, then it handles the required URL encoding of the signature. If your toolkit
doesn't URL encode the final request, then make sure to URL encode the signature before you
include it in the request. Most importantly, make sure the signature is URL encoded only once.
A common mistake is to URL encode it manually during signature formation, and then again
when the toolkit URL encodes the entire request.

API Version 2009-05-15


20
Amazon CloudWatch Developer Guide
Query Example

Query Example
Example ListMetrics API Request

This example uses the Amazon CloudWatch API ListMetrics (p. 60)

http://monitoring.amazonaws.com/?SignatureVersion=2
&Action=ListMetrics
&Version=2009-05-15
&AWSAccessKeyId=XXX YOUR ACCESS KEY XXX
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&Timestamp=2009-02-17T05%3A13%3A00.000Z
&Signature=%XXX YOUR SIGNATURE XXX%3D

Following is the string to sign.

http://monitoring.amazonaws.com/?SignatureVersion=2
AWSAccessKeyId=<Your AWS Access Key Id>
&Action=ListMetrics
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Version=2009-05-15

Following is the signed request.

http://monitoring.amazonaws.com/?Action=ListMetrics
&AWSAccessKeyId=XXX YOUR ACCESS KEY XXX
&SignatureVersion=2
&SignatureMethod=HmacSHA1
&Timestamp=2009-10-17T05%3A13%3A00.000Z
&Signature=<URLEncode(Base64Encode(Signature))>
&Version=2009-05-15

API Version 2009-05-15


21
Amazon CloudWatch Developer Guide
Using the SOAP API

Using the SOAP API


Topics
• WSDL and Schema Definitions (p. 22)
• Programming Language Support (p. 22)
• Request Authentication (p. 22)
• The Response Structure (p. 24)
• Web Services References (p. 25)

WSDL and Schema Definitions


You can access Amazon CloudWatch using the SOAP web services messaging protocol. This
interface is described by a Web Services Description Language (WSDL) document, which defines
the operations and security model for the particular service. The WSDL references an XML Schema
document, which strictly defines the data types that might appear in SOAP requests and responses.
For more information on WSDL and SOAP, see Web Services References (p. 25).

Note

Amazon CloudWatch supports SOAP only through HTTPS.

All schemas have a version number. The version number appears in the URL of a schema file and in
a schema's target namespace. This makes upgrading easy by differentiating requests based on the
version number.

Programming Language Support


Since the SOAP requests and responses in Amazon CloudWatch follow current standards, nearly any
programming language can be used.

Note

AWS provides libraries, sample code, tutorials, and other resources for software developers
who prefer to build applications using language-specific APIs instead of Amazon CloudWatch's
SOAP and Query APIs. These libraries provide basic functions (not included in Amazon
CloudWatch's SOAP and Query APIs), such as request authentication, request retries, and
error handling so that it's easier to get started. Libraries and resources are available for the
following languages:

• Java
• PHP
• Ruby
• Windows and .NET

For libraries and sample code in all languages, go to Sample Code & Libraries.

Request Authentication
Amazon CloudWatch requires you to hash and sign SOAP requests with the current WS-Security
standard, requiring SOAP request messages to be hashed and signed for integrity and non-

API Version 2009-05-15


22
Amazon CloudWatch Developer Guide
Request Authentication

repudiation. WS-Security defines profiles which are used to implement various levels of security.
Amazon CloudWatch secure SOAP messages use the BinarySecurityToken profile, consisting of an
X.509 certificate with an RSA public key.

The following is the content of an insecure GetMetricStatistics operation:

<GetMetricStatistics xmlns="http://monitoring.amazonaws.com/doc/2009-05-15/">
<Statistics>
<member>Average</member>
</Statistics>
<Period>60</Period>
<MeasureName>CPUUtilization</MeasureName>
<Dimensions>
<member>
<Name>InstanceType</Name>
<Value>m1.small</Value>
</member>
<member>
<Name>ImageID</Name>
<Value>ami-11ca2d78</Value>
</member>
</Dimensions>
<StartTime>2009-05-14T19:12:59Z</StartTime>
<EndTime>2009-05-14T19:15:01Z<EndTime>
</GetMetricStatistics>

To secure the request, we add the BinarySecurityToken element.

The secure version of the request begins with the following:

<?xml version="1.0" encoding="UTF-8"?>


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance">
<soap:Header>...</soap:Header>
<soap:Body wsu:Id="id-19451103" xmlns:wsu="http://docs.oasis-open.org/
wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<GetMetricStatistics xmlns="http://monitoring.amazonaws.com/
doc/2009-05-15/">
<Statistics>
<member>Average</member>
</Statistics>
<Period>60</Period>
<measure name>CPUUtilization</measure name>
<Dimensions>
<member>
<Name>InstanceType</Name>
<Value>m1.small</Value>
</member>
<member>
<Name>ImageID</Name>
<Value>ami-11ca2d78</Value>
</member>
</Dimensions>
<StartTime>2009-05-14T19:12:59Z</StartTime>
<EndTime>2009-05-14T19:15:01Z<EndTime>

API Version 2009-05-15


23
Amazon CloudWatch Developer Guide
The Response Structure

</GetMetricStatistics>
</soap:Body>
</soap:Envelope>

If you are matching this against requests generated by Amazon CloudWatch supplied libraries, or
those of another vendor, the following are the most important elements:

Elements

• BinarySecurityToken—Contains the X.509 certificate in base64 encoded PEM format


• Signature—Contains an XML digital signature created using the canonicalization, signature
algorithm, and digest method
• Timestamp—Requests to Amazon CloudWatch are valid within 5 minutes of this value to help
prevent replay attacks

The Response Structure


In response to a request, Amazon CloudWatch returns an XML data structure that conforms to an
XML schema defined as part of the Amazon CloudWatch WSDL. The structure of a XML response
is specific to the associated request. In general, the response data types are named according to
the operation performed and whether the data type is a container (can have children). Examples of
containers include groupSet for security groups and instancesSet for instances. Item elements are
children of containers and their contents vary according to the container's role.

<?xml version="1.0" encoding="UTF-8"?>


<Envelope encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header>...</Header>
<Body>
<GetMetricStatisticsResponse xmlns="http://monitoring.amazonaws.com/
doc/2009-05-15/">
<GetMetricStatisticsResult>
<Label xmlns="http://monitoring.amazonaws.com/
doc/2009-05-15/">CPUUtilization</Label>
<Datapoints>
<member>
<Timestamp>2009-05-14T19:13:00Z</Timestamp>
<Unit>Percent</Unit>
<Samples>1.0</Samples>
<Average>0.0</Average>
</member>
<member>
<Timestamp>2009-05-14T19:12:00Z</Timestamp>
<Unit>Percent</Unit>
<Samples>1.0</Samples>
<Average>0.0</Average>
</member>
</Datapoints>
</GetMetricStatisticsResult>
<ResponseMetadata>
<RequestId>892070df</RequestId>
</ResponseMetadata>
</GetMetricStatisticsResponse>
</Body>

API Version 2009-05-15


24
Amazon CloudWatch Developer Guide
Web Services References

</Envelope>

Web Services References


For more information about using web services, go to any of the following resources:

• Web Service Description Language (WSDL)


• WS-Security BinarySecurityToken Profile

API Version 2009-05-15


25
Amazon CloudWatch Developer Guide
Metrics

Metrics
Topics
• EC2 Metrics (p. 26)
• Elastic Load Balancing Metrics (p. 27)

Amazon CloudWatch collects measures for Amazon EC2 instances and Elastic Load Balancing.

EC2 Metrics
The following metrics are available from each EC2 instance.

Metric Description

CPUUtilization The percentage of allocated EC2 compute units that are currently in use on
the instance. This metric identifies the processing power required to run an
application upon a selected instance.

Units: Percent

NetworkIn The number of bytes received on all network interfaces by the instance.
This metric identifies the volume of incoming network traffic to an
application on a single instance.

Units: Bytes

NetworkOut The number of bytes sent out on all network interfaces by the instance.
This metric identifies the volume of outgoing network traffic to an
application on a single instance.

Units: Bytes

DiskWriteOps Completed write operations to all hard disks available to the instance. This
metric identifies the rate at which an application writes to a hard disk. This
can be used to determine the speed in which an application saves data to
a hard disk.

Units: Count

DiskReadBytes Bytes read from all disks available to the instance. This metric is used to
determine the volume of the data the application reads from the hard disk
of the instance. This can be used to determine the speed of the application
for the customer.

Units: Bytes

DiskReadOps Completed read operations from all disks available to the instances. This
metric identifies the rate at which an application reads a disk. This can be
used to determine the speed in which an application reads data from a
hard disk.

Units: Count

API Version 2009-05-15


26
Amazon CloudWatch Developer Guide
Elastic Load Balancing Metrics

Metric Description

DiskWriteBytes Bytes written to all disks available to the instance. This metric is used to
determine the volume of the data the application writes onto the hard disk
of the instance. This can be used to determine the speed of the application
for the customer.

Units: Bytes

Amazon CloudWatch data for a new EC2 instance typically becomes available within one minute of
the end of the first period of time requested (the aggregation period) in the query. You can use the
currently available dimensions for EC2 instances (for example, ImageID or InstanceType) in order to
refine the metrics returned.

For information about the dimensions you can use with EC2, see Amazon CloudWatch Dimensions (p.
31).

Elastic Load Balancing Metrics


The following metrics are available from the Elastic Load Balancing.

Metric Section

Latency Time taken between a request and the corresponding response as seen by
the load balancer.

Units: Seconds

Valid Statistics: Minimum, Maximum, Average and Count

RequestCount The number of requests processed by the LoadBalancer.

Units: Count/Second

Valid Statistics: Minimum, Maximum and Sum

HealthyHostCount The number of healthy instances. Both Load Balancing dimensions,


LoadBalancerName and AvailabilityZone, should be specified when
retrieving HealthyHostCount.

Units: Count

Valid Statistics: the Average for a LoadBalancer within an Availability Zone

UnHealthyHostCount The number of unhealthy i. Both Load Balancing dimensions,


LoadBalancerName and AvailabilityZone, should be specified when
retrieving UnHealthyHostCount.

Units: Count

Valid Statistics: the Average for a LoadBalancer within an Availability Zone

You can use the currently available dimensions for Elastic Load Balancing to refine the
metrics returned by a query. For example, you could use HealthyHostCount and dimensions
LoadBalancerName and AvailabilityZone to get the Average number of healthy Instances behind
the specified LoadBalancer within the specified Availability Zone for a given period of time. For the
dimensions you can use with the Load Balancing Service, see Amazon CloudWatch Dimensions (p.
31)

API Version 2009-05-15


27
Amazon CloudWatch Developer Guide
Statistics

Statistics
Amazon CloudWatch not only aggregates the raw data coming in, it also computes several statistics on
the data. The following table lists the statistics that you can request:

Statistic Description

Minimum The lowest value observed during the specified period. This can be used to
determine low volumes of activity for your application.

Maximum The highest value observed during the specified period. You can use this
to determine high volumes of activity for your application.

Sum The sum of all values received. This statistic can be useful for determining
the total volume of a metric.

Average The Average of all values received during the specified period. By
comparing this statistic with the minimum and maximum statistics, you can
determine the full scope of a metric and how close the average use is to
the minimum and the maximum. This will allow you to increase or decrease
your resources as needed.

Samples The count (number) of measures used.

Note

This statistic is always returned to show the user the size of the
dataset collected and cannot be explicitly requested.

Statistics are computed within the time period specified in the query. The maximum frequency with
which statistics are gathered by Amazon CloudWatch is 1 minute.

CloudWatch data is generally available from the service within one minute from the end of the time
period requested in the query (the aggregation period). In some cases, delays in data propagation
might cause a delay in data becoming available to CloudWatch. In these instances, you should check
the service’s Health Dashboard for any current operational issues with either Amazon CloudWatch or
the service collecting the data.

API Version 2009-05-15


28
Amazon CloudWatch Developer Guide
About Dimensions

About Dimensions
Amazon CloudWatch organizes data into dimensions. Dimensions are name-value pairs that are
provided by the services feeding data to Amazon CloudWatch. Dimensions can be used to filter result
sets returned by Amazon CloudWatch queries.

If when you don't specify dimensions when using the GetMetricStatistics (p. 55) API to request
metric data from Amazon CloudWatch, all data for the specified measure name will be aggregated and
used to create the statistic (or statistics) that you requested.

The dimensions you can use are to filter your query results depend on which measure is requested
in the query. For example, using the EC2 metric NetworkOut, the available EC2 dimensions are
InstanceType, InstanceId, and ImageId.

Note

Currently, only single dimension aggregation is supported in Amazon CloudWatch, with one
exception: you can get metrics for LoadBalancers within an AvailabilityZone by specifying the
dimensions LoadBalancerName and AvailabilityZone in a single call.

The following example uses two "NetworkOut measures" coming from EC2 instances.

When the first measure comes in, it has the following name, unit, namespace, dimensions, and raw
data value:

• MeasureName—NetworkOut
• Unit—Bytes
• Namespace—AWS/EC2
• Value—0
• Dimension associated—InstanceType, m1.small
• Dimension associated—InstanceId, i-fba30092
• Dimension associated—ImageId, ami-2547a3c

Note

For simplicity, the second measure comes in during a different minute, so that we don't need to
worry about the two measures getting aggregated into the same one-minute chunk.

The second measure has the following name, unit, namespace, dimensions, raw data value:

• MeasureName—NetworkOut
• Unit—Bytes
• Namespace—AWS/EC2
• Value—20
• Dimension associated—InstanceType, m1.small
• Dimension associated—Instance, i-fba30299
• Dimension associated—ImageId, ami-2547a3c

The two measures come in with timestamps as well. They are not listed here, but as noted, to make
the example easier, the two measures come in during different, adjacent minutes. So we now have two
metrics with these attributes and they span two minutes.

API Version 2009-05-15


29
Amazon CloudWatch Developer Guide
About Dimensions

You'll notice that both metrics are of the InstanceType m1.small, and both have the same ImageId
ami-2547a3c, but that they come from different EC2 instances. So if you were to ask a question
specifying either ImageId or InstanceType as the dimension to use when filtering the metric data,
both measures would be combined in the resulting statistic values. However, if you were to specify
your dimension as Instance=i-fba30299, then you would get statistics calculated only from the second
measure.

Let’s get a bit more complex now and ask some more detailed questions, by using a (slightly) longer
time interval.

Because you can currently aggregate along only a single dimension, you can ask questions like the
following (using the previous information):

• What is the Average number of NetworkOut bytes for all of my m1.small instances over a two minute
time interval?

In the above question, the statistic asked for is Average. The time interval (StartTime to EndTime)
is 2 minutes. The measure name is NetworkOut. The dimension used is InstanceType (with the value
m1.small). The answer is the sum of 0 and 20, divided by 2, which equals 10.

• What is the maximum NetworkOut bytes for ami-2547a34c over the last two minutes?

In this question, the statistic asked for is Maximum. The time interval (StartTime to EndTime) is 2
minutes. The measure name is NetworkOut. The dimension is ImageId (with the value ami-2547a3c).
The maximum is the larger of 0 and 20, which is of course 20.

The user scenarios included in this guide provide more detailed examples that you can use to help you
design your own queries. For more information, see User Scenarios (p. 32)

API Version 2009-05-15


30
Amazon CloudWatch Developer Guide
Amazon CloudWatch Dimensions

Amazon CloudWatch Dimensions


Topics
• Dimensions for EC2 Metrics (p. 31)
• Dimensions for Load Balancing Metrics (p. 31)

Dimensions for EC2 Metrics


EC2 instance data can be filtered along any of the following dimensions in the table below.

Dimension Section

ImageId This dimension filters the data you request for all instances running this
EC2 Amazon Machine Image (AMI).

AutoScalingGroupName This dimension filters the data you request for all instances in a specified
capacity group. An AutoScalingGroup is a collection of instances defined
by customers of the Auto Scaling service. This dimension is only available
for EC2 metrics when the instances are in such an AutoScalingGroup.

InstanceId This dimension filters the data you request for only the identified instance.
This allows a user to pinpoint an exact instance from which to monitor data.

InstanceType This dimension filters the data you request for all instances running with
this specified instance type. This allows a user to categorize his data by the
type of instance running. For example, a user might compare data from an
m1.small instance and an m1.large instance to determine which has the
better business value for his application.

Dimensions for Load Balancing Metrics


Load Balancing Service data can be aggregated along any of the following dimensions shown in the
table below.

Load Balancing Section


Metrics

LoadBalancerName This dimension filters the data you request for the specified LoadBalancer
name. A LoadBalancer is represented by a DNS name and provides the
single destination to which all requests intended for your application should
be directed. This metric allows you to examine data from all instances
connected to a single LoadBalancer.

AvailabilityZone This dimension filters the data you request for all instances running in that
EC2 Availability Zone.

API Version 2009-05-15


31
Amazon CloudWatch Developer Guide
User Scenarios

User Scenarios
Topics
• Get Average CPUUtilization for EC2 Instances With a Particular ImageId (p. 33)
• Get Maximum CPUUtilization per EC2 Instance (p. 35)
• Compare RequestCount by Availability Zone for a Load Balanced EC2 Application (p. 37)
• Get Latency Statistics for a LoadBalancer (p. 39)
• Get Total DiskWriteBytes for a Capacity-Managed EC2 Application (p. 41)
• Get A Single Metric Across All Dimensions (p. 43)
• Get Available Metrics Across Multiple Instances (p. 45)

The following sections discuss some common user scenarios for using Amazon CloudWatch. These
scenarios show the API or command line sequence you use to accomplish the given tasks.

Note

The examples in the following sections assume that your instances are in the US Standard
Region. If your instances are in Europe, you must specify the eu-west1 Region by using the --
region eu-west-1 parameter or setting the EC2_REGION environment variable.

API Version 2009-05-15


32
Amazon CloudWatch Developer Guide
Get Average CPUUtilization for EC2
Instances With a Particular ImageId

Get Average CPUUtilization for EC2 Instances


With a Particular ImageId
In this example, we use the GetMetricStatistics API or the mon-get-stats command to
determine Average CPUUtilization for all instances that match a given ImageId. 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.

We assume that the EC2 instances are running an ImageId of ami-2547a34c.

API Example
To get the average CPUUtilization for an ImageId

• Call GetMetricStatistics (p. 55) with the following parameters:

• MeasureName = CPUUtilization
• Period = 60
• Statistics list includes Average
• Dimensions (Name= ImageId, Value= ami-2547a34c)
• Namespace = AWS/EC2
• StartTime = 2009-05-15T00:00:00
• EndTime = 2009-05-16T00:00:00

Command Line Tools Example


To get the average CPUUtilization for an ImageId

• Use the mon-get-stats command as in the following example.

PROMPT> mon-get-stats CPUUtilization --start-time 2009-05-15T00:00:00 --


end-time 2009-05-16T00:00:00 --period 60 --statistics "Average"
--namespace "AWS/EC2" --dimensions "ImageId=ami-2547a34c"

Amazon CloudWatch returns a response similar to the following (the data has been truncated for
brevity):

2009-05-15 22:42:00 6.0 0.38 Percent


2009-05-15 22:48:00 6.0 0.39 Percent
2009-05-15 22:54:00 6.0 0.38 Percent
2009-05-15 23:00:00 6.0 0.38 Percent
2009-05-15 23:06:00 6.0 0.38 Percent
2009-05-15 23:12:00 6.0 0.38 Percent

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, average CPUUtilization,
API Version and unit.
2009-05-15
33
Amazon CloudWatch Developer Guide
Get Average CPUUtilization for EC2
Instances With a Particular ImageId

The operation returns datapoints that are one-minute values for the one-day interval. Each value
represents an average CPUUtilization percentage for EC2 instances running the specified machine
image.

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


34
Amazon CloudWatch Developer Guide
Get Maximum CPUUtilization per EC2 Instance

Get Maximum CPUUtilization per EC2 Instance


In this example, we use the GetMetricStatistics API or the mon-get-stats to determine the
maximum CPUUtilization.

Note

Start and end times must be within the last 14 days.

We assume that you are running multiple EC2 instances for this example.

API Example
To get the maximum CPUUtilization per hour for each EC2 instance for a 3-day period

1. Use the EC2 ec2-describe-instances command to determine the InstanceIds of each of your
running instances, ( e.g. i-5431413d, i-d43242bd, etc.).
2. For each instance, call GetMetricStatistics (p. 55) with the following parameters:

• MeasureName = CPUUtilization
• Period = 3600
• Statistics list includes Maximum
• Dimension (Name=InstanceId, Value="i-5431413d" or other running EC2 instance from
step 1)
• Namespace = AWS/EC2
• StartTime = 2009-05-11T23:18:00
• EndTime = 2009-05-14T23:18:00

Command Line Tools Example


To get the maximum CPUUtilization per EC2 instance

• Use the mon-get-stats command with the following parameters.

mon-get-stats CPUUtilization --end-time 2009-05-13T23:18:00 --start-time


2009-05-11T23:18:00 --period 360 --namespace "AWS/EC2" --statistics
"Maximum" --dimensions "InstanceId=i-5431413d"

Amazon CloudWatch returns the following:

2009-05-11 23:18:00 6.0 0.38 Percent


2009-05-11 23:24:00 6.0 0.38 Percent
2009-05-11 23:30:00 6.0 0.38 Percent
2009-05-11 23:36:00 6.0 0.38 Percent
2009-05-11 23:42:00 6.0 0.38 Percent
2009-05-11 23:48:00 6.0 0.39 Percent
2009-05-11 23:54:00 6.0 0.38 Percent
2009-05-12 00:00:00 6.0 0.38 Percent
2009-05-12 00:06:00 6.0 0.38 Percent
2009-05-12 00:12:00 6.0 0.38 Percent

API Version 2009-05-15


35
Amazon CloudWatch Developer Guide
Get Maximum CPUUtilization per EC2 Instance

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, Maximum CPUUtilization, and unit.

The returned Datapoints (p. 64) are six-minute values for the requested two-day time interval. Each
value represents a maximum CPUUtilization percentage for a single EC2 instance.

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


36
Amazon CloudWatch Developer Guide
Compare RequestCount by Availability
Zone for a Load Balanced EC2 Application

Compare RequestCount by Availability Zone for


a Load Balanced EC2 Application
In this example, we compare RequestCounts by using the GetMetricStatistics API or the mon-
get-stats to retrieve the RequestCount for a LoadBalancer in two different Availability Zones. Statistics
in this example are calculated for six-minute time periods over a 48-hour interval. They are aggregates
over all instances in the specified Availability Zone for one LoadBalancer.

Note

Start and end times must be within the last 14 days.

For this example, we assume the EC2 application is running behind a LoadBalancer
LB1242248298357-7) in two Availability Zones (us-east-1a, us-east-1b).

API Example
To get the RequestCount by Availability Zone for a load balanced EC2 application

1. Call GetMetricStatistics (p. 55) with the following parameters:


• MeasureName = RequestCount
• Period = 360
• Statistics list includes Sum
• Dimensions include:
• Dimension (Name=AvailabilityZone, Value=us-east-1a)
• Dimension (Name=LoadBalancer, Value=LB1242248298357-7)
• Namespace AWS/ELB
• StartTime = 2009-05-12T23:18:00
• EndTime = 2009-05-14T23:18:00
2. Call GetMetricStatistics (p. 55) with the following parameters:
• MeasureName = RequestCount
• Period = 360
• Statistics list includes Sum
• Dimensions include
• Dimension (Name=AvailabilityZone, Value=us-east-1b)
• Dimension (Name=LoadBalancer, Value=LB1242248298357-7)
• Namespace =AWS/ELB
• StartTime = 2009-05-12T23:18:00
• EndTime = 2009-05-14T23:18:00

Command Line Tools Example


To get the RequestCount by Availability Zone for load balanced EC2 application

1. Use the mon-get-stats command with the following parameters.

PROMPT> mon-get-stats RequestCount --end-time 2009-05-14T23:18:00 --


start-time 2009-05-12T23:18:00 --period 360 --namespace "AWS/ELB" --
statistics "Sum" --dimensions "LoadBalancerName=LB1242248298357-7,
AvailabilityZone=us-east-1a"
API Version 2009-05-15
37
Amazon CloudWatch Developer Guide
Compare RequestCount by Availability
Zone for a Load Balanced EC2 Application

Amazon CloudWatch returns the following:

2009-05-13 21:30:00 127.0 127.0 Count


2009-05-13 21:36:00 19.0 19.0 Count

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, sum, and unit.
2. Use the mon-get-stats command with the following parameters.

PROMPT> mon-get-stats RequestCount --end-time 2009-05-14T23:18:00 --


start-time 2009-05-12T23:18:00 --period 360 --namespace "AWS/ELB" --
statistics "Sum" --dimensions "LoadBalancerName=LB1242248298357-7,
AvailabilityZone=us-east-1b"

Amazon CloudWatch returns the following:

2009-05-13 21:30:00 117.0 117.0 Count


2009-05-13 21:36:00 17.0 17.0 Count

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, sum, and unit.

The returned Datapoints (p. 64) lists are six-minute time series values for a 48-hour interval. Each
Datapoint (p. 63) represents a total RequestCount summed for all EC2 instances behind the
LoadBalancer within a single Availability Zone.

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


38
Amazon CloudWatch Developer Guide
Get Latency Statistics for a LoadBalancer

Get Latency Statistics for a LoadBalancer


In this example, we use the GetMetricStatistics API or the mon-get-stats to retrieve average,
minimum, and maximum latency metric data for a LoadBalancer. These statistics are calculated for
one-minute periods over a one-day interval.

Note

Start and end times must be within the last 14 days.

For this example, we assume that an EC2 application is running and is load balanced with the
LoadBalancer LB1242248298357-0.

API Example
To get latency statistics for a LoadBalancer

• Call GetMetricStatistics (p. 55) with the following parameters:

• MeasureName = Latency
• Period = 60
• Statistics list includes Average, Maximum, Minimum
• Dimension (Name=LoadBalancer, Value=LB1242248298357-0)
• Namespace = AWS/ELB
• StartTime = 2009-05-12T23:18:00
• EndTime = 2009-05-13T23:18:00

The returned Datapoints (p. 64) are a list of one-minute values for the one-day interval. Each
Datapoint (p. 63) contains Average, Minimum, and Maximum latency values for requests going
through the application's LoadBalancer.

Command Line Tools Example


To get latency statistics for a LoadBalancer

• Use the mon-get-stats command with the following parameters.

PROMPT> mon-get-stats Latency --end-time 2009-05-13T23:18:00


--start-time 2009-05-12T23:18:00 --period 60 --namespace "AWS/ELB" --
statistics "Average, Maximum, Minimum"
--dimensions "LoadBalancerName=LB1242248298357-0"

Amazon CloudWatch returns the following:

2009-05-13 21:12:00 46.0 2.0888 2.008324 2.22837 Seconds


2009-05-13 21:13:00 53.0 2.1441 2.00405 4.431464 Seconds
2009-05-13 21:14:00 56.0 2.0949 2.005274 2.330432 Seconds
2009-05-13 21:15:00 4.0 2.0518 2.004768 2.089594 Seconds

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
average latency, minimum latency, maximum latency, and unit.
API Version 2009-05-15
39
Amazon CloudWatch Developer Guide
Get Latency Statistics for a LoadBalancer

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


40
Amazon CloudWatch Developer Guide
Get Total DiskWriteBytes for a
Capacity-Managed EC2 Application

Get Total DiskWriteBytes for a Capacity-


Managed EC2 Application
In this example, we use the GetMetricStatistics API or the mon-get-stats with the
DiskWriteBytes measure to retrieve the total bytes written to disk for one capacity 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.

We assume for this example that an EC2 application is running and has a capacity group named
AG1242248298357-22-us-east-1a.

API Example
To get total DiskWriteBytes for a Capacity-managed EC2 Application

Call GetMetricStatistics (p. 55) with the following parameters:

• MeasureName = DiskWriteBytes
• Period = 60
• Statistics list includes Sum
• Unit = Bytes
• Dimension (Name=AutoScalingGroupName, Value=AG1242248298357-22-us-east-1a)
• Namespace = AWS/EC2
• StartTime = 2009-05-13T23:18:00
• EndTime = 2009-05-14T23:18:00

The returned Datapoints (p. 64) are one-minute totals for bytes written for the entire capacity group
over the 24-hour interval.

Command Line Tools Example


To get total DiskWriteBytes for a Capacity-managed EC2 Application

• Use the mon-get-stats command with the following parameters.

mon-get-stats DiskWriteBytes --end-time 2009-05-14T23:18:00


--start-time 2009-05-13T23:18:00 --period 60 --namespace AWS/EC2 --
statistics Sum
--dimensions "AutoScalingGroupName=AG1242248298357-22-us-east-1a"

Amazon CloudWatch returns the following:

2009-05-14 15:52:00 1.0 196608.0 Bytes


2009-05-14 15:53:00 1.0 180224.0 Bytes
2009-05-14 15:54:00 1.0 200704.0 Bytes
2009-05-14 15:55:00 1.0 200704.0 Bytes
2009-05-14 15:56:00 1.0 200704.0 Bytes
2009-05-14 15:57:00 1.0 180224.0 Bytes
2009-05-14 15:58:00 1.0 196608.0 Bytes

API Version 2009-05-15


41
Amazon CloudWatch Developer Guide
Get Total DiskWriteBytes for a
Capacity-Managed EC2 Application

2009-05-14 15:59:00 1.0 372736.0 Bytes


2009-05-14 16:00:00 1.0 258048.0 Bytes

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, sum, and unit.

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


42
Amazon CloudWatch Developer Guide
Get A Single Metric Across All Dimensions

Get A Single Metric Across All Dimensions


In this example, we use the GetMetricStatistics API or the mon-get-stats to get the average
CPUUtilization for all EC2 instances for the account.

Note

Start and end times must be within the last 14 days.

API Example
To get a single metric across all dimensions

• Call GetMetricStatistics (p. 55) with the following parameters:

• MeasureName = CPUUtilization
• Statistics list includes Average
• Namespace = AWS/EC2
• StartTime = 2009-05-13T23:18:00
• EndTime = 2009-05-15T23:18:00
• Period = 360

The returned Datapoints (p. 64) are six-minute values for the two-day interval. Each value
represents an average CPUUtilization percentage for all of your EC2 instances running.

Command Line Tools Example


To get a single metric across all dimensions

• Use the mon-get-stats command with the following parameters.

mon-get-stats CPUUtilization --end-time 2009-05-15T23:18:00 --start-time


2009-05-13T23:18:00 --period 360 --namespace "AWS/EC2" --statistics
"Average"

Amazon CloudWatch returns the following:

2009-05-14 14:18:00 60.0 0.1138 Percent


2009-05-14 15:18:00 60.0 0.1078 Percent
2009-05-14 16:18:00 60.0 0.3322 Percent
2009-05-14 17:18:00 60.0 0.1397 Percent
2009-05-14 18:18:00 60.0 0.1143 Percent
2009-05-14 19:18:00 60.0 0.1082 Percent
2009-05-14 20:18:00 36.0 0.1367 Percent

Note

Amazon CloudWatch provides the data for this function in the following order: date, time,
sample, value, and unit.

API Version 2009-05-15


43
Amazon CloudWatch Developer Guide
Get A Single Metric Across All Dimensions

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use CloudWatch Just click this
feedback link. Thank you.

API Version 2009-05-15


44
Amazon CloudWatch Developer Guide
Get Available Metrics Across Multiple Instances

Get Available Metrics Across Multiple Instances


In this example, we use the ListMetrics API to determine what metrics are available, and then call
GetMetricStatistics API get the Average CPUUtilization for a single instance.

Note

Start and end times must be within the last 14 days.

We assume for this example that your EC2 application is running.

API Example
Using ListMetrics to determine available metrics across multiple instances

1. Call API ListMetrics (p. 60) to generate a list of all of your valid metrics.

This returns a list of metrics. An example metric might look like:

• MeasureName = CPUUtilization
• Dimension (Name=InstanceId, Value=i-5431413d)
• Namespace = AWS/EC2
2. Call GetMetricStatistics (p. 55) with the following parameters:

• Metric = CPUUtilization
• Period = 360
• Statistics list includes Average
• Dimension (Name=InstanceId, Value=i-5431413d)
• Namespace = AWS/EC2
• StartTime = 2009-05-11T23:18:00
• EndTime = 2009-05-13T23:18:00

The returned Datapoints (p. 64) are six-minute time series values for the two-day interval. Each
value represents one of the metrics being monitored for the selected EC2 instance.

Command Line Tools Example


>Using ListMetrics to find determine available metrics across multiple instance

1. Use the mon-list-metrics command.

mon-list-metrics

Amazon CloudWatch returns the following:

CPUUtilization AWS/EC2 {InstanceId=i-5431413d}


CPUUtilization AWS/EC2 {InstanceId=i-d43242bd}
CPUUtilization AWS/EC2 {InstanceId=i-1d3d4d74}
CPUUtilization AWS/EC2 {InstanceId=i-78314111}
CPUUtilization AWS/EC2 {InstanceId=i-d3c8baba}
CPUUtilization AWS/EC2 {InstanceId=i-0d334364}
CPUUtilization AWS/EC2 {InstanceId=i-6732420e}
CPUUtilization AWS/EC2 {InstanceId=i-d93141b0}
CPUUtilization AWS/EC2 {InstanceId=i-e03d4d89}

API Version 2009-05-15


45
Amazon CloudWatch Developer Guide
Get Available Metrics Across Multiple Instances

CPUUtilization AWS/EC2 {InstanceId=i-c93d4da0}


CPUUtilization AWS/EC2 {InstanceId=i-e0304089}
CPUUtilization AWS/EC2 {InstanceId=i-e1304088}
CPUUtilization AWS/EC2 {InstanceId=i-69334300}

Note

Amazon CloudWatch provides the data for this function in the following order:
measurename, namespace, and dimensions.
2. Use the mon-get-stats command with the following parameters.

mon-get-stats CPUUtilization --end-time 2009-05-13T23:18:00 --start-time


2009-05-11T23:18:00 --period 360 --namespace "AWS/EC2" --statistics
"Average" --dimensions "InstanceId=i-5431413d"

Amazon CloudWatch returns the following:

2009-05-11 23:18:00 6.0 0.38 Percent


2009-05-11 23:24:00 6.0 0.38 Percent
2009-05-11 23:30:00 6.0 0.38 Percent
2009-05-11 23:36:00 6.0 0.38 Percent
2009-05-11 23:42:00 6.0 0.38 Percent
2009-05-11 23:48:00 6.0 0.39 Percent
2009-05-11 23:54:00 6.0 0.38 Percent
2009-05-12 00:00:00 6.0 0.38 Percent
2009-05-12 00:06:00 6.0 0.38 Percent
2009-05-12 00:12:00 6.0 0.38 Percent

Note

Amazon CloudWatch returns the data for this function in the following order: date, time,
sample, Average CPUUtilization, and unit.

Give Us Your Feedback


Your input is important to us to help make our documentation helpful and easy to use. Please take a
minute to give us your feedback on how well we were able to help you use Amazon CloudWatch. Just
click this feedback link. Thank you.

API Version 2009-05-15


46
Amazon CloudWatch Developer Guide
WSDL Locations

API Reference

Topics
• WSDL Locations (p. 47)
• API Conventions (p. 47)
• Common Request Parameters (p. 49)
• Error Codes (p. 50)
• Amazon CloudWatch Operations (p. 54)
• Data Types (p. 62)

The following sections of the guide provide reference material for Amazon CloudWatch. For more
information about any concepts or programming tasks associated with the reference material, refer to
the previous chapters in this guide.

WSDL Locations
The WSDL for the Amazon CloudWatch is located online at http://monitoring.amazonaws.com/
doc/2009-05-15/CloudWatch.wsdl.

API Conventions
Data Types and Amazon CloudWatch WSDL
Some libraries can generate code directly from the WSDL. Other libraries require a little more work on
your part.

Values provided as parameters to the various operations must be of the indicated type. Standard XSD
types (like string, boolean, int) are prefixed with xsd:. Complex types defined by the Amazon
CloudWatch WSDL are prefixed. Please look at the individual WSDL for guidance.

For example, the <imagesSet> element in the following XML snippet is of type xsd:string[].

<imagesSet>
<item>

API Version 2009-05-15


47
Amazon CloudWatch Developer Guide
Data Types and Amazon CloudWatch WSDL

<ImageId>ami-61a54008</ImageId>
</item>
<item>
<ImageId>ami-61b54608</ImageId>
</item>
</imagesSet>

API Version 2009-05-15


48
Amazon CloudWatch Developer Guide
Common Request Parameters

Common Request Parameters


All Query operations share a set of common parameters that must be present in each call:

Name Description Required

Action Indicates the action to perform. Yes


Example: GetMetricStatistics

AWSAccessKeyId The Access Key Id for the request sender. This identifies Yes
the account which will be charged for the usage of the
service.
Example: 10QMXFEV71ZS32XQFTR2

Expires The date and time at which the signature included Conditional
in the request expires in the format YYYY-MM-
DDThh:mm:ssZ.
Example: 2009-01-07T15:04:56Z
Conditional: Required if Timestamp is not used

Namespace Namespace is the identifier for the service to wish to No


request information from.
Example: AWS/EC2

Timestamp The date and time at which the request is signed, Conditional
in the format YYYY-MM-DDThh:mm:ssZ. For more
information, go to ISO 8601.
Example: 2009-01-07T15:04:56Z
Conditional: Required if Expired is not used

Signature The request signature. For more information, see Query Yes
API Authentication (p. 19).
Example: Qnpl4Qk/7tINHzfXCiT7VbBatDA=

SignatureMethod The hash algorithm you use to create the request Yes
signature.
Valid values: HmacSHA256 | HmacSHA1. For more
information, see Query API Authentication (p. 19).
Example: HmacSHA256

SignatureVersion The signature version you use to sign the request. Set Yes
this value to 2. For more information, see Query API
Authentication (p. 19).

Version The API version to use, as specified in the WSDL. Yes


Example: 2009-05-15

Note

Requests must include either Timestamp or Expires, but cannot contain both.

Parameter values must be URL-encoded. This is true for any Query parameter passed to Amazon
CloudWatch, and is typically necessary in the Signature parameter. Some clients do this
automatically, but this is not the norm.

API Version 2009-05-15


49
Amazon CloudWatch Developer Guide
Error Codes

Error Codes
Topics
• Overview (p. 50)
• Client Error Codes (p. 50)
• Common Server Error Codes (p. 50)
• Common Client Error Codes (p. 51)

Overview
There are two types of error codes: client and server.

Client error codes suggest that the error was caused by something the client did, such as an
authentication failure or an invalid parameter. In the SOAP API, these error codes are prefixed with
Client. For example: Client.AuthFailure. In the Query API, these errors are accompanied by a
400-series HTTP response code.

Server error codes suggest a server-side issue caused the error and should be reported. In the SOAP
API, these error codes are prefixed with Server. For example: Server.Unavailable. In the Query
API, these errors are accompanied by a 500-series HTTP response code.

Client Error Codes


Error Code Description HTTP SOAP Fault
Status Code Prefix
Code

InvalidInterval The most likely cause is that the end time 400 Bad Client
is set to be before the start time. Request

InvalidMeasureName No metrics exist for the specified measure 400 Bad Client
name. Request

InvalidMetric No metrics exist for the specified measure 400 Bad Client
name and set of dimensions specified. Request

InvalidPeriod The period is either less than 60 seconds, 400 Bad Client
or is not a multiple of sixty seconds. Request

Common Server Error Codes


The following server errors are common across all the services can be returned in addition to the
specific errors listed for each service.

Error Code Description HTTP SOAP Fault


Status Code Prefix
Code

InternalFailure Indicates that the request processing 500 Internal Server


has failed due to some unknown error, Failure Error
exception or failure.

API Version 2009-05-15


50
Amazon CloudWatch Developer Guide
Common Client Error Codes

Error Code Description HTTP SOAP Fault


Status Code Prefix
Code

ServiceUnavailable Indicates that the request has failed due 500 Service Server
to a temporary failure of the server. Unavailable
Error

Common Client Error Codes


The following client errors are common across all the services and can be returned in addition to the
specific errors listed for each service.

Error Code Description HTTP Status SOAP


Code Fault
Code
Prefix

ElementNotSigned An element that is 403 Forbidden Client


marked/configured to
be signed is not signed
(AWS SOAP only).

IncompleteSignature The request signature 400 Bad Client


does not conform to AWS Request
standards.

InvalidAction The action or operation 400 Bad Client


requested is invalid. Request

InvalidClientTokenId The X.509 certificate 403 Forbidden Client


or AWS Access Key Id
provided does not exist in
our records.

InvalidParameterCombination Parameters that must not 400 Bad Client


be used together were Request
used together.

InvalidParameterValue Bad or out of range value 400 Bad Client


was supplied for the input Request
parameter.

InvalidQueryParameter AWS query string 400 Bad Client


is malformed, does Request
not adhere to AWS
standards.

InvalidSecurity The security token 403 Forbidden Client


provided in the input is
missing or expired (AWS
SOAP only).

InvalidSecurityToken Incorrect or invalid data is 400 Bad Client


supplied for the security Request
token.

API Version 2009-05-15


51
Amazon CloudWatch Developer Guide
Common Client Error Codes

Error Code Description HTTP Status SOAP


Code Fault
Code
Prefix

InvalidSOAPRequest The SOAP request is 400 Bad Client


invalid or malformed. Request

MalformedInput The request is invalid or 400 Bad Client


malformed. Request

MalformedQueryString The query string is 400 Bad Client


malformed. Request

MalformedSOAPSignature The signature element 400 Bad Client


in the SOAP request is Request
malformed.

MissingAction The request is missing 400 Bad Client


an action or operation Request
parameter.

MissingAuthenticationToken Request must contain 403 Forbidden Client


either a valid (registered)
AWS Access Key Id or
X.509 certificate.

MissingParameter An input parameter 400 Bad Client


that is mandatory for Request
processing the request is
not supplied.

OptInRequired The AWS Access Key Id 403 Forbidden Client


needs a subscription for
the service

RequestExpired Request is past expires 400 Bad Client


date or more than 15 Request
minutes past request
date.

RequiresSSL The request must 401 Client


be made over SSL Unauthorized
connection.

Throttling Request was denied due 400 Bad Client


to request throttling. Request

WSSecurityMultipleCredentialError More than one credential 400 Bad Client


received in the WS- Request
Security header of the
request.

WSSecurityEncodingTypeError The BinarySecurityToken 400 Bad Client


is not base64 encoded. Request

WSSecurityMultipleX.509Error More than one X.509 400 Bad Client


binary security token Request
received in WS-Security
header of the request.

API Version 2009-05-15


52
Amazon CloudWatch Developer Guide
Common Client Error Codes

Error Code Description HTTP Status SOAP


Code Fault
Code
Prefix

UnknownEnvelopeNamespace The envelope namespace 400 Bad Client


used to define the SOAP Request
request is invalid.

API Version 2009-05-15


53
Amazon CloudWatch Developer Guide
Amazon CloudWatch Operations

Amazon CloudWatch Operations


The following operations are available from the Amazon CloudWatch.

Metric Retrieval Operations:

• GetMetricStatistics (p. 55)


• ListMetrics

API Version 2009-05-15


54
Amazon CloudWatch Developer Guide
GetMetricStatistics

GetMetricStatistics
Description
This call returns data for one or more statistics of given a metric. For more information, see Statistic (p.
8) and Metric (p. 7).

Note

The maximum number of datapoints that the Amazon CloudWatch service will return in a
single GetMetricStatistics request is 1,440. If a request is made that would generate more
datapoints than this amount, Amazon CloudWatch will return an error. You can alter your
request by narrowing the time range (StartTime, EndTime) or increasing the Period in your
single request. You may also get all of the data at the granularity you originally asked for by
making multiple requests with adjacent time ranges.

Request Parameters
Name Description Required

CustomUnit The user-defined CustomUnit applied to a No


Measure. Please see the key term Unit (p. 8).

Type: String

Default: None

Note

CustomUnits are not currently


available.

API Version 2009-05-15


55
Amazon CloudWatch Developer Guide
GetMetricStatistics

Name Description Required

Dimensions Amazon CloudWatch allows you to specify No


one Dimension to further filter metric data on.
If you don't specify a dimension, the service
returns the aggregate of all the measures with
the given measure name and time range. For
more information, see Dimension (p. 7) for more
information on aggregation by dimension.

Exception: LoadBalancerName and


AvailabilityZone can be used together as a
special case of multiple-dimension aggregation.

Constraints: Must correspond to dimensions of


a currently gathered metric. Please see Amazon
CloudWatch Dimensions (p. 31).

Type: String

Default: None

Note

Some API operations take lists


of parameters. These lists are
specified using the following notation:
param.member.n. Values of n are
integers starting from 1. All lists of
parameters must follow this notation,
including lists that only contain one
parameter. For example, an Query
parameter list looks like this:

&attribute.member.1=this
&attribute.member.2=that

EndTime The timestamp to use for determining the Yes


last datapoint to return. This is the last
datapoint to fetch, exclusive. For example,
2008-02-26T20:00:00+00:00.

Type: dateTime (in ISO 8601 format; for more


information, go to http://isotc.iso.org .)

Default: None

MeasureName The measure name that corresponds to the Yes


measure for the gathered metric.

Type: String

Default: None

Constraints: Must be a valid collected metric


with the corresponding measure name, please
see Available Amazon CloudWatch Metrics (p.
26)

API Version 2009-05-15


56
Amazon CloudWatch Developer Guide
GetMetricStatistics

Name Description Required

Namespace The namespace corresponding to the service No


of interest. For example, AWS/EC2 represents
Amazon EC2.

Type: String

Default: None

Period The granularity (in seconds) of the returned No


datapoints.

Type: Integer

Valid Values: 60 or a multiple of 60

Default: 60

Statistics The statistics to be returned for the given Yes


metric.

Type: String

Default: None

StartTime The timestamp of the first datapoint Yes


to return, inclusive. For example,
2008-02-26T19:00:00+00:00. We round your
value down to the nearest minute.

You can set your start time for more than two
weeks in the past. However, you will only get
data for the past two weeks.

Type: dateTime (in ISO 8601 format; for more


information, go to http://isotc.iso.org .)

Default: None

Constraints: Must be before EndTime

Unit The standard unit of Measurement for a given Yes


Measure. Please see the key term Unit (p. 8).

Type: String

Default: None

Valid Values: For more information, see


StandardUnit (p. 67)

Constraints: When using count/second as the


unit, you should use Sum as the statistic instead
of Average. Otherwise, the sample returns as
equal to the number of requests instead of the
number of 60-second intervals. This will cause
the Average to always equals one when the unit
is count/second.

API Version 2009-05-15


57
Amazon CloudWatch Developer Guide
GetMetricStatistics

Response Elements
Name Description

Datapoints A collection of Datapoint (p. 63) elements.

Type: Datapoints (p. 64)

Examples

http://monitoring.amazonaws.com/
?SignatureVersion=2
&Action=GetMetricStatistics
&Version=2009-05-15
&Period=60
&Statistics.member.1=Average
&Namespace=AWS/EC2
&StartTime=2009-01-16T00:00:00
&EndTime=2009-01-16T00:02:00
&MeasureName=CPUUtilization
&Timestamp=2009-01-08-18
&AWSAccessKeyId=XXX YOUR ACCESS KEY XXX
&Signature=%XXX YOUR SIGNATURE XXX%3D

Sample Response

<GetMetricStatisticsResponse>
<GetMetricStatisticsResult>
<Datapoints>
<member>
<Timestamp>2009-01-16T00:00:00Z</Timestamp>
<Unit>Percent</Unit>
<Samples>9.0</Samples>
<Average>0.17777777777777778</Average>
</member>
<member>
<Timestamp>2009-01-16T00:01:00Z</Timestamp>
<Unit>Percent</Unit>
<Samples>8.0</Samples>
<Average>0.1</Average>
</member>
</Datapoints>
<Label>CPUUtilization</Label>
</GetMetricStatisticsResult>
<ResponseMetadata>
<RequestId>a9f8f3a3-e40f-11dd-af0f-cf11f65ec49d</RequestId>
</ResponseMetadata>
</GetMetricStatisticsResponse>

API Version 2009-05-15


58
Amazon CloudWatch Developer Guide
GetMetricStatistics

API Version 2009-05-15


59
Amazon CloudWatch Developer Guide
ListMetrics

ListMetrics
Description
This call returns a list of up to 500 valid metrics for which there is recorded data available to a you and
a NextToken string that can be used to query for the next set of results.

Request Parameters
Name Description Required

NextToken The NextToken parameter is an optional No


parameter that allows you to retrieve the next
set of results for your ListMetrics query.

Type: String

Default: None

Response Elements
Name Description

MetricsList A complete list of all of the metrics being used to


generate statistics for this customer.

Examples

http://monitoring.amazonaws.com/
?SignatureVersion=2
&Action=ListMetrics
&Version=2009-05-15
&Timestamp=2009-01-08T18%3A32%3A53.000Z
&AWSAccessKeyId=XXX YOUR ACCESS KEY XXX
&Signature=%XXX YOUR SIGNATURE XXX%3D
&SignatureMethod=%HmacSHA256

Sample Response

<ListMetricsResponse>
<ListMetricsResult>
<Metrics>
<member>
<Dimensions/>
<MeasureName>NetworkIn</MeasureName>
<Namespace>AWS/EC2</Namespace>
</member>
<member>
<Dimensions>
<member>

API Version 2009-05-15


60
Amazon CloudWatch Developer Guide
ListMetrics

<Name>InstanceId</Name>
<Value>i-c385b3aa</Value>
</member>
</Dimensions>
<MeasureName>CPUUtilization</MeasureName>
<Namespace>AWS/EC2</Namespace>
</member>
<member>
<Dimensions>
<member>
<Name>InstanceId</Name>
<Value>i-c385b3aa</Value>
</member>
</Dimensions>
<MeasureName>NetworkIn</MeasureName>
<Namespace>AWS/EC2</Namespace>
</member>
<member>
<Dimensions>
<member>
<Name>InstanceId</Name>
<Value>i-c385b3aa</Value>
</member>
</Dimensions>
<MeasureName>DiskWriteBytes</MeasureName>
<Namespace>AWS/EC2</Namespace>
</member>
</Metrics>
</ListMetricsResult>
<ResponseMetadata>
<RequestId>4ce61c9b-7345-11de-947b-1d8b67d70c11</RequestId>
</ResponseMetadata>
</ListMetricsResponse>

API Version 2009-05-15


61
Amazon CloudWatch Developer Guide
Data Types

Data Types
Topics
• Datapoint (p. 63)
• Datapoints (p. 64)
• Dimension (p. 65)
• Dimensions (p. 66)
• StandardUnit (p. 67)
• Statistics (p. 68)

The Amazon CloudWatch API contains several data types that various operations use. This section
describes each data type in detail.

Since both the Query and SOAP APIs return the same XML body, the data types described in the
WSDL are used in both.

API Version 2009-05-15


62
Amazon CloudWatch Developer Guide
Datapoint

Datapoint
The Datapoint data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Datapoint.

Name Description Required

Average Average of samples for the datapoint. No


Type: double

Maximum Maximum of the samples used for the datapoint. No


Type: double

Minimum Minimum of samples for the datapoint. No


Type: double

Timestamp Indicates the beginning of the time aggregation for this No


value and samples.
Type: dateTime(in ISO 8601 format; for more
information, go to http://isotc.iso.org.)

Note

The dateTime type uses ISO 8601. Please see


the ISO 8601 information at the following url:
http://isotc.iso.org.

Samples The number of Measurements that contributed to the No


aggregate value of this datapoint.
Type: double

Sum Sum of samples for the datapoint. No


Type: double

Unit Standard unit used for the datapoint. No


Type: String

CustomUnit CustomUnit defined for the datapoint. No


Type: String

API Version 2009-05-15


63
Amazon CloudWatch Developer Guide
Datapoints

Datapoints
The Datapoints data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Datapoints.

Name Description Required

Datapoints A datapoint. Yes


Type: Datapoint (p. 63)

API Version 2009-05-15


64
Amazon CloudWatch Developer Guide
Dimension

Dimension
The Dimension data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Dimension.

Name Description Required

Name Name of the dimension. For more information, Yes


see Amazon CloudWatch Dimensions (p. 31)
Type: String

Value Value of a dimension. Yes


Type: String

API Version 2009-05-15


65
Amazon CloudWatch Developer Guide
Dimensions

Dimensions
The Dimensions data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Dimensions.

Name Description Required

Dimensions A dimension. No
Type: Dimension (p. 65)

API Version 2009-05-15


66
Amazon CloudWatch Developer Guide
StandardUnit

StandardUnit
The StandardUnit data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Standard Units.

Name Description Required

StandardUnit Type: String No


Valid Values: Seconds, Percent, Bytes, Bits,
Count, Bytes, Bits/Second, Count/Second,
and None.

API Version 2009-05-15


67
Amazon CloudWatch Developer Guide
Statistics

Statistics
The Statistics data type.

Relevant Operations
• GetMetricStatistics (p. 55)

Contents
The following table describes the elements contained in Statistics.

Name Description Required

Statistics A statistic. Yes


Type: String
Valid Values: Average, Maximum, Minimum,
Samples,and Sum

API Version 2009-05-15


68
Amazon CloudWatch Developer Guide

Glossary

Access Key Id An alphanumeric token that uniquely identifies a request sender.


This ID is associated with your Secret Access Key.

Amazon Elastic Compute The Amazon Elastic Compute Cloud (Amazon EC2) is a web
Cloud service that enables you to launch and manage server instances in
Amazon's data centers using APIs or available tools and utilities.

Amazon Machine Image An Amazon Machine Image (AMI) is an encrypted machine image
stored in Amazon Simple Storage Service (Amazon S3). It contains
all the information necessary to boot instances of your software.

Amazon Simple Queue Amazon Simple Queue Service (Amazon SQS) offers a reliable,
Service highly scalable, hosted queue for storing messages as they travel
between computers.

Availability Zone Amazon EC2 locations are composed of Regions and Availability
Zones. Availability Zones are distinct locations that are engineered
to be insulated from failures in other Availability Zones and provide
inexpensive, low latency network connectivity to other Availability
Zones in the same Region.

AutoScalingGroup Auto Scaling key term. A capacity group is a representation of a


distributed application running on multiple Amazon Elastic Compute
Cloud (EC2) instances that are to be automatically scaled. Please
see the detailed information on this term in the Automatic Scaling
Service Developer Guide.

dimension Amazon CloudWatch key term. Please see the detailed information
on this term, located at key term Dimension (p. 7).

EC2 instance After an AMI is launched in the cloud, the resulting running system
is called an instance or EC2 instance. By default, you can run up to
20 EC2 instances. All instances based on the same AMI start out
identical and any information on them is lost when the instances
are terminated or fail.

LoadBalancer Elastic Load Balancing key term. An LoadBalancer is represented


by a DNS name and provides the single destination to which all
requests intended for your application should be directed. Please

API Version 2009-05-15


69
Amazon CloudWatch Developer Guide

see the detailed information on this term in the Load Balancing


Service Developer Guide.

Measure Amazon CloudWatch key term. Please see the detailed information
on this term, located at key term Measure (p. 7).

metric Amazon CloudWatch key term. Please see the detailed information
on this term, located at key term Metric (p. 7).

Region Amazon EC2 locations are composed of Regions and Availability


Zones. Regions are geographically dispersed and will be in
separate geographic areas or countries. Regions consist of one or
more Availability Zones.

scaling activity Auto Scaling key term. A scaling activity is a long-running process
that represents a change to your capacity group. Please see the
detailed information on this term in the Automatic Scaling Service
Developer Guide.

Secret Access Key A key assigned to you by Amazon Web Services (AWS) when you
sign up for an AWS account. Used for request authentication.

statistic Amazon CloudWatch key term. Please see the detailed information
on this term, located at key term Statistic (p. 8).

trigger Auto Scaling key term. A trigger defines the metrics and user-
defined thresholds based on those metrics to be used in the
automatic scaling of capacity groups. Please see the detailed
information on this term in the Automatic Scaling Service Developer
Guide.

unbounded Term used in Web Service Definition Language (WSDL), i.e.


maxOccurs="unbounded", meaning that the number of potential
occurences is not limited by a set number. Very often used
when defining a data type that is a list of other types, such as an
unbounded list of integers (element members) or an unbounded list
of other complex types that are element/members of the list being
defined.

unit Amazon CloudWatch key term. Please see the detailed information
on this term, including standard and CustomUnits, located at key
term Unit (p. 8).

API Version 2009-05-15


70
Amazon CloudWatch Developer Guide
Typographical Conventions

Document Conventions

This section lists the common typographical and symbol use conventions for AWS technical
publications.

Typographical Conventions
This section describes common typographical use conventions.

Convention Description/Example

Call-outs A call-out is a number in the body text to give you a visual reference. The
reference point is for further discussion elsewhere.

You can use this resource regularly.

Code in text Inline code samples (including XML) and commands are identified with a
special font.
You can use the command java -version.

Code blocks Blocks of sample code are set apart from the body and marked
accordingly.

# ls -l /var/www/html/index.html
-rw-rw-r-- 1 root root 1872 Jun 21 09:33 /var/www/html/
index.html
# date
Wed Jun 21 09:33:42 EDT 2006

Emphasis Unusual or important words and phrases are marked with a special font.
You must sign up for an account before you can use the service.

Internal cross References to a section in the same document are marked.


references

Logical values, A special font is used for expressions that are important to identify, but are
constants, and regular not code.
expressions, abstracta If the value is null, the returned response will be false.

API Version 2009-05-15


71
Amazon CloudWatch Developer Guide
Typographical Conventions

Convention Description/Example

Product and feature Named AWS products and features are identified on first use.
names Create an Amazon Machine Image (AMI).

Operations In-text references to operations.


Use the GetHITResponse operation.

Parameters In-text references to parameters.


The operation accepts the parameter AccountID.

Response elements In-text references to responses.


A container for one CollectionParent and one or more
CollectionItems.

Technical publication References to other AWS publications. If the reference is hyperlinked, it is


references also underscored.
For detailed conceptual information, see the Amazon Mechanical Turk
Developer Guide.

User entered values A special font marks text that the user types.
At the password prompt, type MyPassword.

User interface controls Denotes named items on the UI for easy identification.
and labels On the File menu, click Properties.

Variables When you see this style, you must change the value of the content when
you copy the text of a sample to a command line.
% ec2-register <your-s3-bucket>/image.manifest
See also the following symbol convention.

API Version 2009-05-15


72
Amazon CloudWatch Developer Guide
Symbol Conventions

Symbol Conventions
This section describes the common use of symbols.

Convention Symbol Description/Example

Mutually (Parentheses | and Within a code description, bar separators denote options from
exclusive | vertical | bars) which one must be chosen.
parameters
% data = hdfread (start | stride | edge)

Optional [square brackets] Within a code description, square brackets denote completely
parameters optional commands or parameters.
XML variable
% sed [-n, -quiet]
text
Use square brackets in XML examples to differentiate them
from tags.

<CustomerId>[ID]</CustomerId>

Variables <arrow brackets> Within a code sample, arrow brackets denote a variable that
must be replaced with a valid value.

% ec2-register <your-s3-bucket>/image.manifest

API Version 2009-05-15


73
Amazon CloudWatch Developer Guide

Dimension, 65
Index Dimensions, 66
RequestId, 19
StandardUnit, 67
A Statistics, 68
Access Key Id, 69 Datapoint, 63
Amazon CloudWatch Datapoints, 64
About Dimensions, 29 Dimension, 65
(see also Dimension, Statistic, Metric, Measure) dimension, 69
API, 54 Dimensions, 7, 66
conceptual overview, 10 aggregation along dimension, 31
data types, 62 (see also Amazon CloudWatch)
dimensions available, 31 Description, 31
(see also Retrieving Metrics Using Dimensions dimensions available for EC2 data, 31
and Statistics)
Getting Started, 16 E
introductory overview, 6 EC2 instance, 69
major features, 6 Amazon CloudWatch dimensions available, 31
metrics available, 26 Amazon CloudWatch metrics available, 26
(see also Retrieving Metrics Using Dimensions Elastic Load Balancing
and Statistics) Amazon CloudWatch metrics available, 27
statistics available, 28 error codes, 50
(see also Retrieving Metrics Using Dimensions
and Statistics)
Amazon Elastic Compute Cloud (Amazon EC2), 69
G
Amazon Machine Image (AMI), 69 GetMetricStatistics, 55
Amazon Simple Queue Service (Amazon SQS), 69
API K
Amazon CloudWatch data types, 62 key terms
common query parameters, 49 Dimension, 7
conventions, 47 measure, 7
data types, 47 Metric, 7
Query, 19 Statistic, 8
SOAP, 22 Unit, 7, 8
User Scenarios, 32, 33, 35, 37, 39, 41, 43, 45
APIs
GetMetricStatistics, 55
L
ListMetrics, 60 ListMetrics, 60
authentication LoadBalancer, 69
Query, 19
signature version 2, 19 M
SOAP, 22 Measure, 7, 69
AutoScalingGroup, 69 Metric, 7
Availability Zone, 69 metric, 69
Metrics
C available metrics, 26, 26, 27
(see also Amazon CloudWatch)
client error codes, 50
Conceptual Overviews
Amazon CloudWatch, 10 N
Regions, 8 Namespace, 7
conventions
API, 47 O
operations
D Amazon CloudWatch, 16, 54
data types, 47 Overviews
Datapoint, 63 Amazon CloudWatch , 5
Datapoints, 64 What is Amazon CloudWatch, 6

API Version 2009-05-15


74
Amazon CloudWatch Developer Guide

P Get Maximum CPUUtilization per EC2 Instance, 35


Get Total DiskWriteBytes for a Capacity-Managed
programming language support, 22
EC2 Application, 41

Q W
Query web services references, 25
API, 19 WSDL, 22
authentication, 19
parameters, 19
query
common parameters, 49

R
region, EC2 region, 69
Regions
conceptual overview, 8
RequestId, 19
response structure, 24
response structure, SOAP, 24
ResponseMetadata
RequestId, 19

S
scaling activity, 69
Secret Access Key, 69
server error codes, 50
signature version 2, 19
SOAP
API, 22
authentication, 22
response structure, 24, 24
WSDL, 22
StandardUnit, 67
Statistic, 8
aggregation of data, computation of statistics on
data, 28
(see also Amazon CloudWatch)
statistic, 69
Statistics, 68

T
trigger, 69

U
unbounded, 69
Unit, 8
unit, CustomUnit, standard unit, 69
User Scenarios
API, 32
Compare RequestCount by Availability Zone for a
Load Balanced EC2 Application, 37
Get A Single Metric Across All Dimensions, 43
Get Available Metrics Across Multiple Instances, 45
Get Average CPUUtilization for EC2 Instances With
a Particular ImageId, 33
Get Latency Statistics for a LoadBalancer, 39

API Version 2009-05-15


75

You might also like