Search in sources :

Example 31 with PutMetricAlarmRequest

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);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) DescribeAlarmsResult(com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult) DBInstance(com.amazonaws.services.rds.model.DBInstance) ArrayList(java.util.ArrayList)

Example 32 with PutMetricAlarmRequest

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;
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)

Example 33 with PutMetricAlarmRequest

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;
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)

Example 34 with PutMetricAlarmRequest

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);
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 35 with PutMetricAlarmRequest

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;
}
Also used : PutMetricAlarmRequest(com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)

Aggregations

PutMetricAlarmRequest (com.amazonaws.services.cloudwatch.model.PutMetricAlarmRequest)60 Test (org.junit.Test)9 Dimension (com.amazonaws.services.cloudwatch.model.Dimension)5 ArrayList (java.util.ArrayList)4 AmazonCloudWatch (com.amazonaws.services.cloudwatch.AmazonCloudWatch)1 DescribeAlarmsResult (com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult)1 PutMetricAlarmResult (com.amazonaws.services.cloudwatch.model.PutMetricAlarmResult)1 LoadBalancer (com.amazonaws.services.elasticbeanstalk.model.LoadBalancer)1 DBInstance (com.amazonaws.services.rds.model.DBInstance)1 LinkedList (java.util.LinkedList)1