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


Java Datapoint类代码示例

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


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

示例1: getInstanceAverageLoad

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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: testAverageBurnRateCalculation

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testAverageBurnRateCalculation() {
    List<Datapoint> dpList = new ArrayList<>();
    dpList.add(getDatapoint(1.0, new Date(2016, 10, 9, 5, 00, 00)));
    dpList.add(getDatapoint(2.0, new Date(2016, 10, 9, 9, 00, 00)));
    dpList.add(getDatapoint(3.0, new Date(2016, 10, 9, 13, 00, 00)));
    dpList.add(getDatapoint(4.0, new Date(2016, 10, 9, 17, 00, 00)));
    dpList.add(getDatapoint(5.0, new Date(2016, 10, 9, 21, 00, 00)));
    dpList.add(getDatapoint(6.0, new Date(2016, 10, 10, 1, 00, 00)));
    dpList.add(getDatapoint(7.0, new Date(2016, 10, 10, 5, 00, 00)));
    dpList.add(getDatapoint(8.0, new Date(2016, 10, 10, 9, 00, 00)));
    dpList.add(getDatapoint(9.0, new Date(2016, 10, 10, 13, 00, 00)));
    dpList.add(getDatapoint(10.0, new Date(2016, 10, 10, 17, 00, 00)));
    Double burnRate = AWSUtils.calculateAverageBurnRate(dpList);
    assertTrue("Received a null response", burnRate != null);
    assertTrue("BurnRate value is negative", burnRate > 0.0);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:TestAWSUtils.java

示例3: testAverageBurnRateCalculationWithResetToZero

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testAverageBurnRateCalculationWithResetToZero() {
    List<Datapoint> dpList = new ArrayList<>();
    dpList.add(getDatapoint(4.0, new Date(2016, 10, 9, 5, 00, 00)));
    dpList.add(getDatapoint(5.0, new Date(2016, 10, 9, 9, 00, 00)));
    dpList.add(getDatapoint(6.0, new Date(2016, 10, 9, 13, 00, 00)));
    dpList.add(getDatapoint(7.0, new Date(2016, 10, 9, 17, 00, 00)));
    dpList.add(getDatapoint(8.0, new Date(2016, 10, 9, 21, 00, 00)));
    dpList.add(getDatapoint(9.0, new Date(2016, 10, 10, 1, 00, 00)));
    dpList.add(getDatapoint(0.0, new Date(2016, 10, 10, 5, 00, 00)));
    dpList.add(getDatapoint(1.0, new Date(2016, 10, 10, 9, 00, 00)));
    dpList.add(getDatapoint(2.0, new Date(2016, 10, 10, 13, 00, 00)));
    dpList.add(getDatapoint(3.0, new Date(2016, 10, 10, 17, 00, 00)));
    Double burnRate = AWSUtils.calculateAverageBurnRate(dpList);
    assertTrue("Received a null response", burnRate != null);
    assertTrue("BurnRate value is negative", burnRate > 0.0);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:19,代码来源:TestAWSUtils.java

示例4: testCurrentBurnRateCalculation

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testCurrentBurnRateCalculation() {
    List<Datapoint> dpList = new ArrayList<>();
    dpList.add(getDatapoint(1.0, new Date(2016, 10, 9, 5, 00, 00)));
    dpList.add(getDatapoint(2.0, new Date(2016, 10, 9, 9, 00, 00)));
    dpList.add(getDatapoint(3.0, new Date(2016, 10, 9, 13, 00, 00)));
    dpList.add(getDatapoint(4.0, new Date(2016, 10, 9, 17, 00, 00)));
    dpList.add(getDatapoint(5.0, new Date(2016, 10, 9, 21, 00, 00)));
    dpList.add(getDatapoint(6.0, new Date(2016, 10, 10, 1, 00, 00)));
    dpList.add(getDatapoint(7.0, new Date(2016, 10, 10, 5, 00, 00)));
    dpList.add(getDatapoint(8.0, new Date(2016, 10, 10, 9, 00, 00)));
    Double burnRate = AWSUtils.calculateCurrentBurnRate(dpList);
    assertTrue("Received a null response", burnRate != null);
    assertTrue("BurnRate value is negative", burnRate > 0.0);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:TestAWSUtils.java

示例5: testCurrentBurnRateCalculationWithResetToZero

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testCurrentBurnRateCalculationWithResetToZero() {
    List<Datapoint> dpList = new ArrayList<>();
    dpList.add(getDatapoint(4.0, new Date(2016, 10, 9, 13, 00, 00)));
    dpList.add(getDatapoint(5.0, new Date(2016, 10, 9, 17, 00, 00)));
    dpList.add(getDatapoint(6.0, new Date(2016, 10, 9, 21, 00, 00)));
    dpList.add(getDatapoint(7.0, new Date(2016, 10, 10, 1, 00, 00)));
    dpList.add(getDatapoint(0.0, new Date(2016, 10, 10, 5, 00, 00)));
    dpList.add(getDatapoint(1.0, new Date(2016, 10, 10, 9, 00, 00)));
    dpList.add(getDatapoint(2.0, new Date(2016, 10, 10, 13, 00, 00)));
    dpList.add(getDatapoint(3.0, new Date(2016, 10, 10, 17, 00, 00)));
    Double burnRate = AWSUtils.calculateCurrentBurnRate(dpList);
    assertTrue("Received a null response", burnRate != null);
    assertTrue("BurnRate value is negative", burnRate > 0.0);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:TestAWSUtils.java

示例6: getBacklogBytes

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例7: shouldCountBytesWhenSingleDataPointReturned

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例8: shouldCountBytesWhenMultipleDataPointsReturned

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例9: Datum

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的package包/类
public Datum(Datapoint d, String metric, Statistic statistic) {
	switch (statistic) {
	case Sum:
		value = d.getSum();
		break;
	case Maximum:
		value = d.getMaximum();
		break;
	case Minimum:
		value = d.getMinimum();
		break;
	case SampleCount:
		value = d.getSampleCount();
		break;
	default:
		value = d.getAverage();
	}
	
	timestamp = d.getTimestamp().getTime();
	this.metric = metric;
	this.statistic = statistic.name();
	this.unit = d.getUnit();
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:24,代码来源:Datum.java

示例10: testAllStatistics

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例11: testDimensions

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例12: testDimensionSelect

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例13: testDimensionSelectRegex

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例14: testGetDimensionsUsesNextToken

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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

示例15: testExtendedStatistics

import com.amazonaws.services.cloudwatch.model.Datapoint; //导入依赖的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


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