use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method setupAllAlarms.
/**
* Setup all alarms.
*/
public void setupAllAlarms() {
List<PutMetricAlarmRequest> l;
DescribeAlarmsResult r;
// This is the topic where all alarm notification are sent
String topicArn = resources.getStackInstanceNotificationTopicArn();
// setup the alarms for the id generator
DBInstance instance = resources.getIdGeneratorDatabase();
l = createAllAlarmsForDatabase(instance, topicArn);
r = describeAllAlarmsForDatabase(instance);
resources.setIdGeneratorDatabaseAlarms(r);
// setup the alarms for the stack instances database.
instance = resources.getStackInstancesDatabase();
l = createAllAlarmsForDatabase(instance, topicArn);
r = describeAllAlarmsForDatabase(instance);
resources.setStackInstancesDatabaseAlarms(r);
// setup the alarms for the stack table databases.
List<DescribeAlarmsResult> lr = new ArrayList<DescribeAlarmsResult>();
List<DBInstance> tblInstances = resources.getStackInstanceTablesDatabases();
for (DBInstance i : tblInstances) {
l = createAllAlarmsForDatabase(i, topicArn);
r = describeAllAlarmsForDatabase(i);
lr.add(r);
}
resources.setStackInstanceTablesDatabaseAlarms(lr);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method createSwapUsage.
/**
* Low-Free-Storage-Space
*/
public static PutMetricAlarmRequest createSwapUsage(DBInstance instances, String topicArn) {
if (instances == null)
throw new IllegalArgumentException("DBInstance cannot be null");
if (topicArn == null)
throw new IllegalArgumentException("Topic ARN cannot be null");
PutMetricAlarmRequest alarmRequest = createDefaultPutMetricRequest(instances, topicArn);
alarmRequest.setAlarmName(instances.getDBInstanceIdentifier() + SWAP_USAGE);
Double swapUsageThreshold = 1024.0 * 1024.0 * 512.0;
alarmRequest.withStatistic(STATISTIC_AVERAGE).withMetricName(METRIC_SWAP_USAGE).withComparisonOperator(ComparisonOperator.GreaterThanThreshold).withThreshold(swapUsageThreshold).withEvaluationPeriods(2).withPeriod(FIVE_MINUTES_IN_SECONDS);
return alarmRequest;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method createLowFreeStorage.
/**
* Low-Free-Storage-Space
*/
public static PutMetricAlarmRequest createLowFreeStorage(DBInstance instances, String topicArn) {
if (instances == null)
throw new IllegalArgumentException("DBInstance cannot be null");
if (topicArn == null)
throw new IllegalArgumentException("Topic ARN cannot be null");
PutMetricAlarmRequest alarmRequest = createDefaultPutMetricRequest(instances, topicArn);
alarmRequest.setAlarmName(instances.getDBInstanceIdentifier() + LOW_FREE_STOREAGE_SPACE);
Double tenPercentGB = ((double) instances.getAllocatedStorage()) * 0.1;
Double tenPercentBytes = tenPercentGB * Constants.BYTES_PER_GIGABYTE;
// CPUUtilization >= 90 for 5 minutes
alarmRequest.withStatistic(STATISTIC_AVERAGE).withMetricName(METRIC_FREE_STOREAGE_SPACE).withComparisonOperator(ComparisonOperator.LessThanOrEqualToThreshold).withThreshold(tenPercentBytes).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
return alarmRequest;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmSetupTest method testCreateAllPutMetricAlarmRequests.
@Test
public void testCreateAllPutMetricAlarmRequests() {
PutMetricAlarmRequest expectedReq = ElbAlarmTestHelper.getExpectedPutMetricAlarmRequest();
List<PutMetricAlarmRequest> expectedReqs = new ArrayList<>();
expectedReqs.add(expectedReq);
String loadBalancerName = "loadBalancer";
List<PutMetricAlarmRequest> reqs = ElbAlarmSetup.createAllPutMetricAlarmRequests("prefix", loadBalancerName, resources.getStackInstanceNotificationTopicArn());
assertEquals(expectedReqs, reqs);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class ElbAlarmTestHelper method getExpectedPutMetricAlarmRequest.
public static PutMetricAlarmRequest getExpectedPutMetricAlarmRequest() {
final String prefix = "prefix";
final String expectedAlarmName = prefix + "-unlhealthy-instance-count-alarm";
PutMetricAlarmRequest expectedReq = ElbAlarmTestHelper.getExpectedBasePutMetricAlarmRequest();
expectedReq.setAlarmName(expectedAlarmName);
expectedReq.setStatistic(STATISTIC_MAX);
expectedReq.setMetricName(METRIC_UNHEALTHY_COUNT);
expectedReq.setComparisonOperator(ComparisonOperator.GreaterThanThreshold);
expectedReq.setThreshold(new Double(0));
expectedReq.setEvaluationPeriods(2);
expectedReq.setPeriod(FIVE_MINUTES_IN_SECONDS);
return expectedReq;
}
Aggregations