Search in sources :

Example 6 with Dimension

use of com.amazonaws.services.cloudwatch.model.Dimension in project jmxtrans by jmxtrans.

the class MapEntryToDimensionTest method simpleDimensionIsCreated.

@Test
public void simpleDimensionIsCreated() {
    Dimension dimension = mapEntryToDimension.apply(ImmutableMap.of("name", (Object) "some_name", "value", (Object) "some_value"));
    assertThat(dimension.getName()).isEqualTo("some_name");
    assertThat(dimension.getValue()).isEqualTo("some_value");
}
Also used : Dimension(com.amazonaws.services.cloudwatch.model.Dimension) Test(org.junit.Test)

Example 7 with Dimension

use of com.amazonaws.services.cloudwatch.model.Dimension in project jmxtrans by jmxtrans.

the class MapEntryToDimensionTest method nameMustBeGiven.

@Test(expected = IllegalArgumentException.class)
public void nameMustBeGiven() {
    Dimension dimension = mapEntryToDimension.apply(ImmutableMap.of("no_name", (Object) "some_name", "value", (Object) "some_value"));
    assertThat(dimension.getName()).isEqualTo("some_name");
    assertThat(dimension.getValue()).isEqualTo("some_value");
}
Also used : Dimension(com.amazonaws.services.cloudwatch.model.Dimension) Test(org.junit.Test)

Example 8 with Dimension

use of com.amazonaws.services.cloudwatch.model.Dimension in project jmxtrans by jmxtrans.

the class MapEntryToDimensionTest method dimensionIsCreatedFromEC2Metadata.

@Test
@Ignore("Should run on EC2 to be actually relevant")
public void dimensionIsCreatedFromEC2Metadata() {
    Dimension dimension = mapEntryToDimension.apply(ImmutableMap.of("name", (Object) "some_name", "value", (Object) "$AmiId"));
    assertThat(dimension.getName()).isEqualTo("some_name");
    assertThat(dimension.getValue()).isEqualTo("null");
}
Also used : Dimension(com.amazonaws.services.cloudwatch.model.Dimension) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with Dimension

use of com.amazonaws.services.cloudwatch.model.Dimension in project aws-doc-sdk-examples by awsdocs.

the class PutMetricAlarm method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply an alarm name and instance id\n" + "Ex: DeleteAlarm <alarm-name> <instance-id>\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String alarmName = args[0];
    String instanceId = args[1];
    final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.defaultClient();
    Dimension dimension = new Dimension().withName("InstanceId").withValue(instanceId);
    PutMetricAlarmRequest request = new PutMetricAlarmRequest().withAlarmName(alarmName).withComparisonOperator(ComparisonOperator.GreaterThanThreshold).withEvaluationPeriods(1).withMetricName("CPUUtilization").withNamespace("AWS/EC2").withPeriod(60).withStatistic(Statistic.Average).withThreshold(70.0).withActionsEnabled(false).withAlarmDescription("Alarm when server CPU utilization exceeds 70%").withUnit(StandardUnit.Seconds).withDimensions(dimension);
    PutMetricAlarmResult response = cw.putMetricAlarm(request);
    System.out.printf("Successfully created alarm with name %s", alarmName);
}
Also used : PutMetricAlarmResult(com.amazonaws.services.cloudwatch.model.PutMetricAlarmResult) PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) AmazonCloudWatch(com.amazonaws.services.cloudwatch.AmazonCloudWatch) Dimension(com.amazonaws.services.cloudwatch.model.Dimension)

Example 10 with Dimension

use of com.amazonaws.services.cloudwatch.model.Dimension 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)

Aggregations

Dimension (com.amazonaws.services.cloudwatch.model.Dimension)10 Test (org.junit.Test)5 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)2 PutMetricDataRequest (com.amazonaws.services.cloudwatch.model.PutMetricDataRequest)2 Map (java.util.Map)2 MetricDatum (com.amazonaws.services.cloudwatch.model.MetricDatum)1 PutMetricAlarmRequest (com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)1 PutMetricAlarmResult (com.amazonaws.services.cloudwatch.model.PutMetricAlarmResult)1 PutMetricDataResult (com.amazonaws.services.cloudwatch.model.PutMetricDataResult)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Nullable (javax.annotation.Nullable)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1