Search in sources :

Example 6 with MetricDatum

use of com.amazonaws.services.cloudwatch.model.MetricDatum in project camel by apache.

the class CwProducer method getMetricData.

private List<MetricDatum> getMetricData(Exchange exchange) {
    Object body = exchange.getIn().getBody();
    if (body instanceof List) {
        return CastUtils.cast((List<?>) body);
    }
    if (body instanceof MetricDatum) {
        return Arrays.asList((MetricDatum) body);
    }
    MetricDatum metricDatum = new MetricDatum().withMetricName(determineName(exchange)).withValue(determineValue(exchange)).withUnit(determineUnit(exchange)).withTimestamp(determineTimestamp(exchange));
    setDimension(metricDatum, exchange);
    return Arrays.asList(metricDatum);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) MetricDatum(com.amazonaws.services.cloudwatch.model.MetricDatum)

Example 7 with MetricDatum

use of com.amazonaws.services.cloudwatch.model.MetricDatum in project chassis by Kixeye.

the class MetricsCloudWatchReporter method addDatum.

private void addDatum(String name, double value, LinkedList<PutMetricDataRequest> requests, Date timestamp) {
    if (logger.isDebugEnabled()) {
        logger.debug("Adding Datum {} with value {} at {}", name, value, timestamp);
    }
    if (requests.isEmpty() || requests.getLast().getMetricData().size() == MAX_CLOUDWATCH_DATUM_PER_REQUEST) {
        requests.add(createRequest());
    }
    PutMetricDataRequest request = requests.getLast();
    MetricDatum datum = new MetricDatum().withTimestamp(timestamp).withValue(value).withMetricName(name).withUnit(StandardUnit.None).withDimensions(createDimensions());
    request.withMetricData(datum);
}
Also used : PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) MetricDatum(com.amazonaws.services.cloudwatch.model.MetricDatum)

Aggregations

MetricDatum (com.amazonaws.services.cloudwatch.model.MetricDatum)7 PutMetricDataRequest (com.amazonaws.services.cloudwatch.model.PutMetricDataRequest)6 Test (org.junit.Test)2 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1 Dimension (com.amazonaws.services.cloudwatch.model.Dimension)1 PutMetricDataResult (com.amazonaws.services.cloudwatch.model.PutMetricDataResult)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1