Amazon.CloudWatch.AmazonCloudWatchClient.GetMetricStatistics C# (CSharp) Метод

GetMetricStatistics() публичный Метод

Gets statistics for the specified metric.

Amazon CloudWatch retains metric data as follows:

  • Data points with a period of 60 seconds (1 minute) are available for 15 days

  • Data points with a period of 300 seconds (5 minute) are available for 63 days

  • Data points with a period of 3600 seconds (1 hour) are available for 455 days (15 months)

Note that CloudWatch started retaining 5-minute and 1-hour metric data as of 9 July 2016.

The maximum number of data points returned from a single call is 1,440. If you request more than 1,440 data points, Amazon CloudWatch returns an error. To reduce the number of data points, you can narrow the specified time range and make multiple requests across adjacent time ranges, or you can increase the specified period. A period can be as short as one minute (60 seconds). Note that data points are not returned 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-hour period, Amazon CloudWatch aggregates all data points with time stamps that fall within each one-hour period. Therefore, the number of values aggregated by CloudWatch is larger than the number of data points returned.

For a list of metrics and dimensions supported by AWS services, see the Amazon CloudWatch Metrics and Dimensions Reference in the Amazon CloudWatch User Guide.

/// Request processing has failed due to some unknown error, exception, or failure. /// /// Parameters that cannot be used together were used together. /// /// The value of an input parameter is bad or out-of-range. /// /// An input parameter that is required is missing. ///
public GetMetricStatistics ( GetMetricStatisticsRequest request ) : GetMetricStatisticsResponse
request Amazon.CloudWatch.Model.GetMetricStatisticsRequest Container for the necessary parameters to execute the GetMetricStatistics service method.
Результат Amazon.CloudWatch.Model.GetMetricStatisticsResponse
        public GetMetricStatisticsResponse GetMetricStatistics(GetMetricStatisticsRequest request)
        {
            var marshaller = new GetMetricStatisticsRequestMarshaller();
            var unmarshaller = GetMetricStatisticsResponseUnmarshaller.Instance;

            return Invoke<GetMetricStatisticsRequest,GetMetricStatisticsResponse>(request, marshaller, unmarshaller);
        }

Usage Example

Пример #1
3
    public static void CWGetMetricStatistics()
    {
      #region CWGetMetricStatistics
      var client = new AmazonCloudWatchClient();

      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 + "%");
        }
      }
      #endregion

      Console.ReadLine();
    }
All Usage Examples Of Amazon.CloudWatch.AmazonCloudWatchClient::GetMetricStatistics