Example usage for com.amazonaws.services.cloudwatch.model PutMetricAlarmRequest setEvaluationPeriods

List of usage examples for com.amazonaws.services.cloudwatch.model PutMetricAlarmRequest setEvaluationPeriods

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudwatch.model PutMetricAlarmRequest setEvaluationPeriods.

Prototype


public void setEvaluationPeriods(Integer evaluationPeriods) 

Source Link

Document

The number of periods over which data is compared to the specified threshold.

Usage

From source file:com.pinterest.arcee.autoscaling.AwsAlarmManager.java

License:Apache License

@Override
public void putAlarmToPolicy(String action, AsgAlarmBean asgAlarmBean) throws Exception {
    PutMetricAlarmRequest request = new PutMetricAlarmRequest();
    List<String> ARNs = new LinkedList<>();
    ARNs.add(action);/* w w w .  j  a  va2  s.c o m*/
    request.setAlarmActions(ARNs);
    if (asgAlarmBean.getFrom_aws_metric()) {
        request.setNamespace(METRIC_NAMESPACE);
    } else {
        request.setNamespace(getNameSpace(asgAlarmBean.getGroup_name()));
    }
    request.setDimensions(Arrays.asList(getDimention(asgAlarmBean.getGroup_name())));
    request.setActionsEnabled(true);

    request.setComparisonOperator(ComparisonOperator.fromValue(asgAlarmBean.getComparator()));
    request.setEvaluationPeriods(asgAlarmBean.getEvaluation_time());
    request.setPeriod(60);
    request.setStatistic(Statistic.Average);

    request.setMetricName(asgAlarmBean.getMetric_name());
    request.setThreshold(asgAlarmBean.getThreshold());
    request.setAlarmName(getAlarmName(asgAlarmBean));

    acwClient.putMetricAlarm(request);
}