use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmTestHelper method getExpectedBasePutMetricAlarmRequest.
public static PutMetricAlarmRequest getExpectedBasePutMetricAlarmRequest() {
final String expectedDesc = "Setup by Stack Builder: " + ElbAlarmSetup.class.getName();
final boolean expectedActionsEnabled = true;
final Collection<String> expectedAlarmActions = new ArrayList<String>();
expectedAlarmActions.add("topicArn");
final String expectedNameSpace = NAMESPACE_ELB;
Dimension expectedDimension = new Dimension().withName(DIMENSION_NAME_LOAD_BALANCER).withValue("loadBalancer");
Collection<Dimension> expectedDimensions = new ArrayList<Dimension>();
expectedDimensions.add(expectedDimension);
PutMetricAlarmRequest expectedReq = new PutMetricAlarmRequest();
expectedReq.setAlarmDescription(expectedDesc);
expectedReq.setActionsEnabled(expectedActionsEnabled);
expectedReq.setAlarmActions(expectedAlarmActions);
expectedReq.setNamespace(expectedNameSpace);
expectedReq.setDimensions(expectedDimensions);
return expectedReq;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetupTest method testCreateDefaultPutMetricRequest.
@Test
public void testCreateDefaultPutMetricRequest() {
PutMetricAlarmRequest expected = new PutMetricAlarmRequest();
expected.setAlarmDescription("Setup by: " + RdsAlarmSetup.class.getName());
expected.setActionsEnabled(true);
expected.withAlarmActions(topicArn);
expected.setNamespace(NAME_SPACES_AWS_RDS);
expected.withDimensions(new Dimension().withName(DB_INSTANCE_IDENTIFIER).withValue(databaseIdentifer));
PutMetricAlarmRequest result = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
assertEquals(expected, result);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetupTest method testCreateLowFreeableMemoryLargeInstances.
@Test
public void testCreateLowFreeableMemoryLargeInstances() {
// the free able memory alarm is a function of the instances size
// Set the size to large
dbInstance.setDBInstanceClass(DATABASE_INSTANCE_CLASS_M1_LARGE);
Double totalMemory = Constants.getDatabaseClassMemrorySizeBytes(DATABASE_INSTANCE_CLASS_M1_LARGE);
System.out.println("Large memory total: " + totalMemory + " bytes");
PutMetricAlarmRequest expected = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
expected.setAlarmName(databaseIdentifer + "-Low-Freeable-Memory");
Double eightPercent = totalMemory - (totalMemory * 0.8);
// Average FreeableMemory < 80% for 1 consecutive period of 5 minutes
expected.withStatistic("Average").withMetricName(METRIC_FREEABLE_MEMORY).withComparisonOperator(ComparisonOperator.LessThanThreshold).withThreshold(eightPercent).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
PutMetricAlarmRequest result = RdsAlarmSetup.createLowFreeableMemory(dbInstance, topicArn);
assertEquals(expected, result);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetupTest method testHightCPU.
@Test
public void testHightCPU() {
PutMetricAlarmRequest expected = RdsAlarmSetup.createDefaultPutMetricRequest(dbInstance, topicArn);
expected.setAlarmName(databaseIdentifer + HIGH_CPU_UTILIZATION);
expected.withStatistic("Average").withMetricName(METRIC_HIGH_CPU_UTILIZATION).withComparisonOperator(ComparisonOperator.GreaterThanOrEqualToThreshold).withThreshold(90.0).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
PutMetricAlarmRequest result = RdsAlarmSetup.createHighCPUUtilization(dbInstance, topicArn);
assertEquals(expected, result);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmSetup method createDefaultPutMetricAlarmRequest.
public static PutMetricAlarmRequest createDefaultPutMetricAlarmRequest(String loadBalancerName, String topicArn) {
if (loadBalancerName == null)
throw new IllegalArgumentException("Load balancer name cannot be null");
if (topicArn == null)
throw new IllegalArgumentException("Topic ARN cannot be null");
PutMetricAlarmRequest alarmRequest = new PutMetricAlarmRequest();
alarmRequest.setAlarmDescription("Setup by Stack Builder: " + ElbAlarmSetup.class.getName());
alarmRequest.setActionsEnabled(true);
alarmRequest.withAlarmActions(topicArn);
alarmRequest.setNamespace(NAMESPACE_ELB);
Collection<Dimension> dimensions = new ArrayList<Dimension>();
dimensions.add(new Dimension().withName(DIMENSION_NAME_LOAD_BALANCER).withValue(loadBalancerName));
alarmRequest.setDimensions(dimensions);
alarmRequest.withDimensions();
return alarmRequest;
}
Aggregations