AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
The maximum number of data points that can be queried is 50,850, whereas the maximum
number of data points returned from a single GetMetricStatistics
request
is 1,440. If you make a request that generates more than 1,440 data points, Amazon
CloudWatch returns an error. In such a case, you can alter the request by narrowing
the specified time range or increasing the specified period. Alternatively, you can
make multiple requests across adjacent time ranges. GetMetricStatistics
does not return the data in chronological order.
Amazon CloudWatch aggregates data points based on the length of the period
that you specify. For example, if you request statistics with a one-minute granularity,
Amazon CloudWatch aggregates data points with time stamps that fall within the same
one-minute period. In such a case, the data points queried can greatly outnumber the
data points returned.
The following examples show various statistics allowed by the data point query maximum
of 50,850 when you call GetMetricStatistics
on Amazon EC2 instances with
detailed (one-minute) monitoring enabled:
For information about the namespace, metric names, and dimensions that other Amazon Web Services products use to send metrics to CloudWatch, go to Amazon CloudWatch Metrics, Namespaces, and Dimensions Reference in the Amazon CloudWatch Developer Guide.
Namespace: Amazon.CloudWatch.Model
Assembly: AWSSDK.dll
Version: (assembly version)
public class GetMetricStatisticsRequest : AmazonCloudWatchRequest IRequestEvents
The GetMetricStatisticsRequest type exposes the following members
Name | Description | |
---|---|---|
GetMetricStatisticsRequest() |
Name | Type | Description | |
---|---|---|---|
Dimensions | System.Collections.Generic.List<Amazon.CloudWatch.Model.Dimension> |
Gets and sets the property Dimensions.
A list of dimensions describing qualities of the metric. |
|
EndTime | System.DateTime |
Gets and sets the property EndTime.
The time stamp to use for determining the last datapoint to return. The value specified is exclusive; results will include datapoints up to the time stamp specified. The time stamp must be in ISO 8601 UTC format (e.g., 2014-09-03T23:00:00Z). |
|
MetricName | System.String |
Gets and sets the property MetricName.
The name of the metric, with or without spaces. |
|
Namespace | System.String |
Gets and sets the property Namespace.
The namespace of the metric, with or without spaces. |
|
Period | System.Int32 |
Gets and sets the property Period.
The granularity, in seconds, of the returned datapoints. |
|
StartTime | System.DateTime |
Gets and sets the property StartTime.
The time stamp to use for determining the first datapoint to return. The value specified is inclusive; results include datapoints with the time stamp specified. The time stamp must be in ISO 8601 UTC format (e.g., 2014-09-03T23:00:00Z).
Data that is timestamped 24 hours or more in the past may take in excess of 48 hours
to become available from submission time using |
|
Statistics | System.Collections.Generic.List<System.String> |
Gets and sets the property Statistics.
The metric statistics to return. For information about specific statistics returned by GetMetricStatistics, see Statistics in the Amazon CloudWatch Developer Guide. |
|
Unit | Amazon.CloudWatch.StandardUnit |
Gets and sets the property Unit.
The unit for the metric. |
This example shows how to get statistics for a metric.
var client = new AmazonCloudWatchClient(); var dimension = new Dimension { Name = "InstanceType", Value = "t1.micro" }; var request = new GetMetricStatisticsRequest { Dimensions = new List<Dimension>() { dimension }, EndTime = DateTime.Today, MetricName = "CPUUtilization", Namespace = "AWS/EC2", // Get statistics by day. Period = (int)TimeSpan.FromDays(1).TotalSeconds, // Get statistics for the past month. StartTime = DateTime.Today.Subtract(TimeSpan.FromDays(30)), Statistics = new List<string>() { "Minimum" }, Unit = StandardUnit.Percent }; var response = client.GetMetricStatistics(request); if (response.Datapoints.Count > 0) { foreach (var point in response.Datapoints) { Console.WriteLine(point.Timestamp.ToShortDateString() + " " + point.Minimum + "%"); } }
.NET Framework:
Supported in: 4.5, 4.0, 3.5
.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8
.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8