use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method createDefaultPutMetricRequest.
/**
* @param instances
* @param topicArn
* @param alarmRequest
*/
static PutMetricAlarmRequest createDefaultPutMetricRequest(DBInstance instances, String topicArn) {
PutMetricAlarmRequest alarmRequest = new PutMetricAlarmRequest();
alarmRequest.setAlarmDescription("Setup by: " + RdsAlarmSetup.class.getName());
alarmRequest.setActionsEnabled(true);
alarmRequest.withAlarmActions(topicArn);
alarmRequest.setNamespace(NAME_SPACES_AWS_RDS);
alarmRequest.withDimensions(new Dimension().withName(DB_INSTANCE_IDENTIFIER).withValue(instances.getDBInstanceIdentifier()));
return alarmRequest;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method createAllAlarmsForDatabase.
/**
* Create all of the alarms for a given database.
* @param databaseInstancesName
* @return
*/
public List<PutMetricAlarmRequest> createAllAlarmsForDatabase(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");
List<PutMetricAlarmRequest> alarms = new LinkedList<PutMetricAlarmRequest>();
// Swap usage
alarms.add(createSwapUsage(instances, topicArn));
// High-Write-Latency
alarms.add(createHighWriteLatency(instances, topicArn));
// High CPU
alarms.add(createHighCPUUtilization(instances, topicArn));
// Low free storage
alarms.add(createLowFreeStorage(instances, topicArn));
// Add all alarms from the lsit
for (PutMetricAlarmRequest alarm : alarms) {
log.info("Creating or updating alarm: " + alarm);
client.putMetricAlarm(alarm);
}
return alarms;
}
use of com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class RdsAlarmSetup method createLowFreeableMemory.
/**
* Create a Low-Freeable-Memory alarm.
*
* @param databaseInstancesName
* @return
*/
public static PutMetricAlarmRequest createLowFreeableMemory(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_FREEABLE_MEMORY_NAME);
Double totalMemory = Constants.getDatabaseClassMemrorySizeBytes(instances.getDBInstanceClass());
Double eightPercent = totalMemory - (totalMemory * 0.8);
// Average FreeableMemory < 80% for 1 consecutive period of 5 minutes
alarmRequest.withStatistic(STATISTIC_AVERAGE).withMetricName(METRIC_FREEABLE_MEMORY).withComparisonOperator(ComparisonOperator.LessThanThreshold).withThreshold(eightPercent).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 RdsAlarmSetup method createHighWriteLatency.
/**
* High-Write-Latency
*
* @param databaseInstancesName
* @return
*/
public static PutMetricAlarmRequest createHighWriteLatency(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() + HIGH_WRITE_LATENCY);
Double hundredMS = 0.1;
// WriteLatency >= 0.1 for 1 consecutive period of 5 minutes
alarmRequest.withStatistic(STATISTIC_AVERAGE).withMetricName(METRIC_WRITE_LATENCY).withComparisonOperator(ComparisonOperator.GreaterThanOrEqualToThreshold).withThreshold(hundredMS).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 RdsAlarmSetup method createHighCPUUtilization.
/**
* High-CPU-Utilization
*/
public static PutMetricAlarmRequest createHighCPUUtilization(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() + HIGH_CPU_UTILIZATION);
Double nintyPercent = 90.0;
// CPUUtilization >= 90 for 5 minutes
alarmRequest.withStatistic(STATISTIC_AVERAGE).withMetricName(METRIC_HIGH_CPU_UTILIZATION).withComparisonOperator(ComparisonOperator.GreaterThanOrEqualToThreshold).withThreshold(nintyPercent).withEvaluationPeriods(1).withPeriod(FIVE_MINUTES_IN_SECONDS);
return alarmRequest;
}
Aggregations