List of usage examples for com.amazonaws.services.cloudwatch.model MetricDatum getValue
public Double getValue()
The value for the metric.
From source file:com.boundlessgeo.suite.geoserver.cloudwatch.aws.CloudwatchSender.java
License:Open Source License
/** * Invoked by spring on a timer to get and send from all metric providers */// w w w .ja v a2s.c o m public void sendAllMetricsToConsole() { if (!enabled) { logger.debug("Metrics are disabled...returning"); return; } logger.debug("Sending all metrics"); for (MetricProvider mp : providers) { for (MetricDatum md : mp.getMetrics()) { logger.debug("Sending statistic {}", md.getMetricName()); //PutMetricDataRequest request = new PutMetricDataRequest().withNamespace("geoserver").withMetricData(md); //cloudwatch.putMetricDataAsync(request); logger.debug("Sent statistic {}", md.getMetricName()); System.out.println(md.getMetricName() + " value: " + md.getValue()); } } }
From source file:com.github.lpezet.antiope.metrics.aws.BlockingRequestBuilder.java
License:Open Source License
/** * Summarizes the given datum into the statistics of the respective unique metric. *//*from w ww . j a va2 s . c o m*/ private void summarize(MetricDatum pDatum, Map<String, MetricDatum> pUniqueMetrics) { Double pValue = pDatum.getValue(); if (pValue == null) { return; } List<Dimension> oDims = pDatum.getDimensions(); Collections.sort(oDims, DimensionComparator.INSTANCE); String oMetricName = pDatum.getMetricName(); String k = oMetricName + Jackson.toJsonString(oDims); MetricDatum oStatDatum = pUniqueMetrics.get(k); if (oStatDatum == null) { oStatDatum = new MetricDatum().withDimensions(pDatum.getDimensions()).withMetricName(oMetricName) .withUnit(pDatum.getUnit()).withStatisticValues(new StatisticSet().withMaximum(pValue) .withMinimum(pValue).withSampleCount(0.0).withSum(0.0)); pUniqueMetrics.put(k, oStatDatum); } StatisticSet oStat = oStatDatum.getStatisticValues(); oStat.setSampleCount(oStat.getSampleCount() + 1.0); oStat.setSum(oStat.getSum() + pValue); if (pValue > oStat.getMaximum()) { oStat.setMaximum(pValue); } else if (pValue < oStat.getMinimum()) { oStat.setMinimum(pValue); } }
From source file:com.github.lpezet.antiope.metrics.aws.BlockingRequestBuilder.java
License:Open Source License
/** * Returns a metric datum cloned from the given one. * Made package private only for testing purposes. *//* w w w. j av a 2 s .c om*/ final MetricDatum cloneMetricDatum(MetricDatum pMd) { return new MetricDatum().withDimensions(pMd.getDimensions()) // a new collection is created .withMetricName(pMd.getMetricName()).withStatisticValues(pMd.getStatisticValues()) .withTimestamp(pMd.getTimestamp()).withUnit(pMd.getUnit()).withValue(pMd.getValue()); }
From source file:com.github.lpezet.antiope.metrics.aws.spi.MetricData.java
License:Open Source License
/** * Returns a new metric datum cloned from the given metric datum, but * replacing the dimensions with the newly specified ones. *///from w w w . j a v a 2 s .co m public static MetricDatum newMetricDatum(MetricDatum pFrom, Dimension... pDimensions) { return new MetricDatum().withMetricName(pFrom.getMetricName()).withDimensions(pDimensions) .withUnit(pFrom.getUnit()).withValue(pFrom.getValue()) .withStatisticValues(pFrom.getStatisticValues()).withTimestamp(pFrom.getTimestamp()); }
From source file:uk.gov.gchq.gaffer.performancetesting.aws.PublishAccumuloMetricsToCloudWatch.java
License:Apache License
private void publishMetrics(final List<MetricDatum> metrics) { LOGGER.info("Submitting " + metrics.size() + " metrics to CloudWatch"); // CloudWatch throws InvalidParameterValue if a value has a high level of precision and is very close to 0 for (final MetricDatum metric : metrics) { if (Math.abs(metric.getValue()) < 0.0001) { metric.setValue(0.0);/* w w w . j a v a 2 s . c om*/ } } // There's a limit on the AWS API which means only 20 metrics can be submitted at once! for (int i = 0; i < metrics.size(); i += 20) { final List<MetricDatum> metricBatch = metrics.subList(i, i + 20 > metrics.size() ? metrics.size() : i + 20); try { final PutMetricDataResult response = this.cloudwatch.putMetricData( new PutMetricDataRequest().withNamespace("Accumulo").withMetricData(metricBatch)); LOGGER.debug(response.getSdkResponseMetadata().getRequestId()); } catch (final AmazonCloudWatchException e) { LOGGER.error("Failed publishing the following metrics to CloudWatch: " + metricBatch, e); } } }