当前位置: 首页>>代码示例>>Java>>正文


Java GetMetricStatisticsRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest的典型用法代码示例。如果您正苦于以下问题:Java GetMetricStatisticsRequest类的具体用法?Java GetMetricStatisticsRequest怎么用?Java GetMetricStatisticsRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GetMetricStatisticsRequest类属于com.amazonaws.services.cloudwatch.model包,在下文中一共展示了GetMetricStatisticsRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstanceAverageLoad

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
private double getInstanceAverageLoad(AmazonCloudWatchClient cloudWatchClient, String instanceId) {

        long offsetInMilliseconds = 1000 * 60 * 60;
        GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
                .withStartTime(new Date(new Date().getTime() - offsetInMilliseconds))
                .withNamespace("AWS/EC2")
                .withPeriod(60 * 60)
                .withDimensions(new Dimension().withName("InstanceId").withValue(instanceId))
                .withMetricName("CPUUtilization")
                .withStatistics("Average", "Maximum")
                .withEndTime(new Date());
        GetMetricStatisticsResult getMetricStatisticsResult = cloudWatchClient.getMetricStatistics(request);

        double avgCPUUtilization = 0;
        List dataPoint = getMetricStatisticsResult.getDatapoints();
        for (Object aDataPoint : dataPoint) {
            Datapoint dp = (Datapoint) aDataPoint;
            avgCPUUtilization = dp.getAverage();
        }

        return avgCPUUtilization;
    }
 
开发者ID:gadelkareem,项目名称:aws-client,代码行数:23,代码来源:Controller.java

示例2: getBacklogBytes

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
/**
 * Gets total size in bytes of all events that remain in Kinesis stream between specified
 * instants.
 *
 * @return total size in bytes of all Kinesis events after specified instant
 */
public long getBacklogBytes(final String streamName, final Instant countSince,
    final Instant countTo) throws TransientKinesisException {
  return wrapExceptions(new Callable<Long>() {

    @Override
    public Long call() throws Exception {
      Minutes period = Minutes.minutesBetween(countSince, countTo);
      if (period.isLessThan(Minutes.ONE)) {
        return 0L;
      }

      GetMetricStatisticsRequest request = createMetricStatisticsRequest(streamName,
          countSince, countTo, period);

      long totalSizeInBytes = 0;
      GetMetricStatisticsResult result = cloudWatch.getMetricStatistics(request);
      for (Datapoint point : result.getDatapoints()) {
        totalSizeInBytes += point
            .getSum()
            .longValue();
      }
      return totalSizeInBytes;
    }
  });
}
 
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:SimplifiedKinesisClient.java

示例3: shouldCountBytesWhenSingleDataPointReturned

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void shouldCountBytesWhenSingleDataPointReturned() throws Exception {
  Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
  Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
  Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
  GetMetricStatisticsRequest metricStatisticsRequest =
      underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);
  GetMetricStatisticsResult result = new GetMetricStatisticsResult()
      .withDatapoints(new Datapoint().withSum(1.0));

  given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willReturn(result);

  long backlogBytes = underTest.getBacklogBytes(STREAM, countSince, countTo);

  assertThat(backlogBytes).isEqualTo(1L);
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:SimplifiedKinesisClientTest.java

示例4: shouldCountBytesWhenMultipleDataPointsReturned

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void shouldCountBytesWhenMultipleDataPointsReturned() throws Exception {
  Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
  Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
  Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
  GetMetricStatisticsRequest metricStatisticsRequest =
      underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);
  GetMetricStatisticsResult result = new GetMetricStatisticsResult()
      .withDatapoints(
          new Datapoint().withSum(1.0),
          new Datapoint().withSum(3.0),
          new Datapoint().withSum(2.0)
      );

  given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willReturn(result);

  long backlogBytes = underTest.getBacklogBytes(STREAM, countSince, countTo);

  assertThat(backlogBytes).isEqualTo(6L);
}
 
开发者ID:apache,项目名称:beam,代码行数:21,代码来源:SimplifiedKinesisClientTest.java

示例5: shouldHandleGetBacklogBytesError

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
private void shouldHandleGetBacklogBytesError(
    Exception thrownException,
    Class<? extends Exception> expectedExceptionClass) {
  Instant countSince = new Instant("2017-04-06T10:00:00.000Z");
  Instant countTo = new Instant("2017-04-06T11:00:00.000Z");
  Minutes periodTime = Minutes.minutesBetween(countSince, countTo);
  GetMetricStatisticsRequest metricStatisticsRequest =
      underTest.createMetricStatisticsRequest(STREAM, countSince, countTo, periodTime);

  given(cloudWatch.getMetricStatistics(metricStatisticsRequest)).willThrow(thrownException);
  try {
    underTest.getBacklogBytes(STREAM, countSince, countTo);
    failBecauseExceptionWasNotThrown(expectedExceptionClass);
  } catch (Exception e) {
    assertThat(e).isExactlyInstanceOf(expectedExceptionClass);
  } finally {
    reset(kinesis);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:SimplifiedKinesisClientTest.java

示例6: matches

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
public boolean matches(Object o) {
 GetMetricStatisticsRequest request = (GetMetricStatisticsRequest) o;
 if (request == null) return false;
 if (namespace != null && !namespace.equals(request.getNamespace())){
   return false;
 }
 if (metricName != null && !metricName.equals(request.getMetricName())){
   return false;
 }
 if (!dimensions.equals(request.getDimensions())) {
   return false;
 }
 if (period != null && !period.equals(request.getPeriod())) {
     return false;
 }
 return true;
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:18,代码来源:CloudWatchCollectorTest.java

示例7: testMetricPeriod

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testMetricPeriod() {
  new CloudWatchCollector(
          "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount\n  period_seconds: 100\n  range_seconds: 200\n  delay_seconds: 300", client).register(registry);

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest) anyObject()))
          .thenReturn(new GetMetricStatisticsResult());

  registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance"}, new String[]{"aws_elb", ""});


  Mockito.verify(client).getMetricStatistics((GetMetricStatisticsRequest) argThat(
          new GetMetricStatisticsRequestMatcher()
                  .Namespace("AWS/ELB")
                  .MetricName("RequestCount")
                  .Period(100)
  ));
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:19,代码来源:CloudWatchCollectorTest.java

示例8: testDefaultPeriod

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testDefaultPeriod() {
  new CloudWatchCollector(
                  "---\nregion: reg\nperiod_seconds: 100\nrange_seconds: 200\ndelay_seconds: 300\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount", client).register(registry);

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest) anyObject()))
          .thenReturn(new GetMetricStatisticsResult());

  registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance"}, new String[]{"aws_elb", ""});


  Mockito.verify(client).getMetricStatistics((GetMetricStatisticsRequest) argThat(
          new GetMetricStatisticsRequestMatcher()
                  .Namespace("AWS/ELB")
                  .MetricName("RequestCount")
                  .Period(100)
  ));
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:19,代码来源:CloudWatchCollectorTest.java

示例9: testAllStatistics

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testAllStatistics() throws Exception {
  new CloudWatchCollector(
      "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount", client).register(registry);

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(1.0)
              .withMaximum(2.0).withMinimum(3.0).withSampleCount(4.0).withSum(5.0)));

  assertEquals(1.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_maximum", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
  assertEquals(3.0, registry.getSampleValue("aws_elb_request_count_minimum", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
  assertEquals(4.0, registry.getSampleValue("aws_elb_request_count_sample_count", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
  assertEquals(5.0, registry.getSampleValue("aws_elb_request_count_sum", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:18,代码来源:CloudWatchCollectorTest.java

示例10: testDimensions

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testDimensions() throws Exception {
  new CloudWatchCollector(
      "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount\n  aws_dimensions:\n  - AvailabilityZone\n  - LoadBalancerName", client).register(registry);
  
  Mockito.when(client.listMetrics((ListMetricsRequest)argThat(
      new ListMetricsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimensions("AvailabilityZone", "LoadBalancerName"))))
      .thenReturn(new ListMetricsResult().withMetrics(
        new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myLB")),
        new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myLB"), new Dimension().withName("ThisExtraDimensionIsIgnored").withValue("dummy")),
        new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("b"), new Dimension().withName("LoadBalancerName").withValue("myOtherLB"))));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "a").Dimension("LoadBalancerName", "myLB"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));
  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "b").Dimension("LoadBalancerName", "myOtherLB"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(3.0)));

  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myLB"}), .01);
  assertEquals(3.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "b", "myOtherLB"}), .01);
  assertNull(registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name", "this_extra_dimension_is_ignored"}, new String[]{"aws_elb", "", "a", "myLB", "dummy"}));
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:26,代码来源:CloudWatchCollectorTest.java

示例11: testDimensionSelect

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testDimensionSelect() throws Exception {
  new CloudWatchCollector(
      "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount\n  aws_dimensions:\n  - AvailabilityZone\n  - LoadBalancerName\n  aws_dimension_select:\n    LoadBalancerName:\n    - myLB", client).register(registry);
  Mockito.when(client.listMetrics((ListMetricsRequest)argThat(
      new ListMetricsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimensions("AvailabilityZone", "LoadBalancerName"))))
      .thenReturn(new ListMetricsResult().withMetrics(
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myLB")),
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("b"), new Dimension().withName("LoadBalancerName").withValue("myLB")),
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myOtherLB"))));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "a").Dimension("LoadBalancerName", "myLB"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "b").Dimension("LoadBalancerName", "myLB"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));

  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myLB"}), .01);
  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "b", "myLB"}), .01);
  assertNull(registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myOtherLB"}));
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:26,代码来源:CloudWatchCollectorTest.java

示例12: testDimensionSelectRegex

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testDimensionSelectRegex() throws Exception {
  new CloudWatchCollector(
      "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount\n  aws_dimensions:\n  - AvailabilityZone\n  - LoadBalancerName\n  aws_dimension_select_regex:\n    LoadBalancerName:\n    - myLB(.*)", client).register(registry);

  Mockito.when(client.listMetrics((ListMetricsRequest) argThat(
      new ListMetricsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimensions("AvailabilityZone", "LoadBalancerName"))))
      .thenReturn(new ListMetricsResult().withMetrics(
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myLB1")),
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("b"), new Dimension().withName("LoadBalancerName").withValue("myLB2")),
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myOtherLB"))));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest) argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "a").Dimension("LoadBalancerName", "myLB1"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest) argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "b").Dimension("LoadBalancerName", "myLB2"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));

  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myLB1"}), .01);
  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "b", "myLB2"}), .01);
  assertNull(registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myOtherLB"}));
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:27,代码来源:CloudWatchCollectorTest.java

示例13: testGetDimensionsUsesNextToken

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testGetDimensionsUsesNextToken() throws Exception {
  new CloudWatchCollector(
          "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: RequestCount\n  aws_dimensions:\n  - AvailabilityZone\n  - LoadBalancerName\n  aws_dimension_select:\n    LoadBalancerName:\n    - myLB", client).register(registry);
  
  Mockito.when(client.listMetrics((ListMetricsRequest)argThat(
      new ListMetricsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimensions("AvailabilityZone", "LoadBalancerName"))))
      .thenReturn(new ListMetricsResult().withNextToken("ABC"));
  Mockito.when(client.listMetrics((ListMetricsRequest)argThat(
      new ListMetricsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimensions("AvailabilityZone", "LoadBalancerName").NextToken("ABC"))))
      .thenReturn(new ListMetricsResult().withMetrics(
          new Metric().withDimensions(new Dimension().withName("AvailabilityZone").withValue("a"), new Dimension().withName("LoadBalancerName").withValue("myLB"))));

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("RequestCount").Dimension("AvailabilityZone", "a").Dimension("LoadBalancerName", "myLB"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withAverage(2.0)));

  assertEquals(2.0, registry.getSampleValue("aws_elb_request_count_average", new String[]{"job", "instance", "availability_zone", "load_balancer_name"}, new String[]{"aws_elb", "", "a", "myLB"}), .01);
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:21,代码来源:CloudWatchCollectorTest.java

示例14: testExtendedStatistics

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
@Test
public void testExtendedStatistics() throws Exception {
  new CloudWatchCollector(
      "---\nregion: reg\nmetrics:\n- aws_namespace: AWS/ELB\n  aws_metric_name: Latency\n  aws_extended_statistics:\n  - p95\n  - p99.99", client).register(registry);

  HashMap<String, Double> extendedStatistics = new HashMap<String, Double>();
  extendedStatistics.put("p95", 1.0);
  extendedStatistics.put("p99.99", 2.0);

  Mockito.when(client.getMetricStatistics((GetMetricStatisticsRequest)argThat(
      new GetMetricStatisticsRequestMatcher().Namespace("AWS/ELB").MetricName("Latency"))))
      .thenReturn(new GetMetricStatisticsResult().withDatapoints(
          new Datapoint().withTimestamp(new Date()).withExtendedStatistics(extendedStatistics)));

  assertEquals(1.0, registry.getSampleValue("aws_elb_latency_p95", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
  assertEquals(2.0, registry.getSampleValue("aws_elb_latency_p99_99", new String[]{"job", "instance"}, new String[]{"aws_elb", ""}), .01);
}
 
开发者ID:prometheus,项目名称:cloudwatch_exporter,代码行数:18,代码来源:CloudWatchCollectorTest.java

示例15: monitorCPUUsage

import com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest; //导入依赖的package包/类
public void monitorCPUUsage() {
	AmazonCloudWatchClient cloudClient = new AmazonCloudWatchClient(
			getAwsCredentials());
	GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
	Calendar cal = Calendar.getInstance();
	request.setEndTime(cal.getTime());
	cal.add(Calendar.MINUTE, -5);
	request.setStartTime(cal.getTime());
	request.setNamespace("AWS/EC2");
	List<String> statistics = new ArrayList<String>();
	statistics.add("Maximium");
	statistics.add("Average");
	request.setStatistics(statistics);
	request.setMetricName("CPUUtilization");
	request.setPeriod(300);
	Dimension dimension = new Dimension();
	dimension.setName("InstanceId");
	dimension.setValue("i-d93fa2a4");
	List<Dimension> dimensions = new ArrayList<Dimension>();
	dimensions.add(dimension);
	request.setDimensions(dimensions);
	GetMetricStatisticsResult result = cloudClient
			.getMetricStatistics(request);
	List<Datapoint> dataPoints = result.getDatapoints();
	for (Datapoint dataPoint : dataPoints) {
		System.out.println(dataPoint.getAverage());
	}

}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:30,代码来源:Master.java


注:本文中的com.amazonaws.services.cloudwatch.model.GetMetricStatisticsRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。