Search in sources :

Example 1 with PutMetricDataResult

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;
}
Also used : AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult)

Example 2 with PutMetricDataResult

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);
}
Also used : AmazonCloudWatch(com.amazonaws.services.cloudwatch.AmazonCloudWatch) PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult) MetricDatum(com.amazonaws.services.cloudwatch.model.MetricDatum) Dimension(com.amazonaws.services.cloudwatch.model.Dimension)

Example 3 with PutMetricDataResult

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);
}
Also used : ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ListMetricsRequest(com.amazonaws.services.cloudwatch.model.ListMetricsRequest) SortedSet(java.util.SortedSet) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ListMetricsResult(com.amazonaws.services.cloudwatch.model.ListMetricsResult) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest) Function(java.util.function.Function) TreeSet(java.util.TreeSet) PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) DescribeTargetGroupsRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) ListClustersResult(com.amazonaws.services.elasticmapreduce.model.ListClustersResult) DescribeTargetGroupsResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult) Iterator(java.util.Iterator) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) Publisher(org.reactivestreams.Publisher) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult) ListHostedZonesRequest(com.amazonaws.services.route53.model.ListHostedZonesRequest) ListClustersRequest(com.amazonaws.services.elasticmapreduce.model.ListClustersRequest) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult) Assert(org.junit.Assert) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult) Test(org.junit.Test)

Aggregations

PutMetricDataResult (com.amazonaws.services.cloudwatch.model.PutMetricDataResult)3 PutMetricDataRequest (com.amazonaws.services.cloudwatch.model.PutMetricDataRequest)2 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)1 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1 AmazonCloudWatchClient (com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)1 Dimension (com.amazonaws.services.cloudwatch.model.Dimension)1 ListMetricsRequest (com.amazonaws.services.cloudwatch.model.ListMetricsRequest)1 ListMetricsResult (com.amazonaws.services.cloudwatch.model.ListMetricsResult)1 MetricDatum (com.amazonaws.services.cloudwatch.model.MetricDatum)1 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 DescribeLoadBalancersRequest (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest)1 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult)1 DescribeTargetGroupsRequest (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest)1 DescribeTargetGroupsResult (com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult)1 ListClustersRequest (com.amazonaws.services.elasticmapreduce.model.ListClustersRequest)1