use of com.amazonaws.services.cloudwatch.model.PutMetricDataResult in project nifi by apache.
the class PutCloudWatchMetric method putMetricData.
protected PutMetricDataResult putMetricData(PutMetricDataRequest metricDataRequest) throws AmazonClientException {
final AmazonCloudWatchClient client = getClient();
final PutMetricDataResult result = client.putMetricData(metricDataRequest);
return result;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricDataResult in project aws-doc-sdk-examples by awsdocs.
the class PutMetricData method main.
public static void main(String[] args) {
final String USAGE = "To run this example, supply a data point:\n" + "Ex: PutMetricData <data_point>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
Double data_point = Double.parseDouble(args[0]);
final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.defaultClient();
Dimension dimension = new Dimension().withName("UNIQUE_PAGES").withValue("URLS");
MetricDatum datum = new MetricDatum().withMetricName("PAGES_VISITED").withUnit(StandardUnit.None).withValue(data_point).withDimensions(dimension);
PutMetricDataRequest request = new PutMetricDataRequest().withNamespace("SITE/TRAFFIC").withMetricData(datum);
PutMetricDataResult response = cw.putMetricData(request);
System.out.printf("Successfully put data point %f", data_point);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricDataResult in project iep by Netflix.
the class PaginationTest method cloudwatchPut.
@Test
public void cloudwatchPut() throws Exception {
final AtomicInteger n = new AtomicInteger();
Function<PutMetricDataRequest, PutMetricDataResult> f = r -> {
if (n.getAndIncrement() > 0) {
Assert.fail("non-paginated API called more than once");
}
return new PutMetricDataResult();
};
Publisher<PutMetricDataResult> publisher = Pagination.createPublisher(new PutMetricDataRequest(), f);
Iterable<PutMetricDataResult> iter = Flowable.fromPublisher(publisher).blockingIterable();
int count = 0;
for (PutMetricDataResult r : iter) {
++count;
}
Assert.assertEquals(1, count);
}
Aggregations