Search in sources :

Example 36 with PutMetricAlarmRequest

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

Example 37 with PutMetricAlarmRequest

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

Example 38 with PutMetricAlarmRequest

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

Example 39 with PutMetricAlarmRequest

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

Example 40 with PutMetricAlarmRequest

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

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