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");
}
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");
}
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");
}
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);
}
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);
}
Aggregations