List of usage examples for com.amazonaws.services.cloudwatch.model PutMetricAlarmRequest setStatistic
public void setStatistic(Statistic statistic)
The statistic for the metric specified in MetricName
, other than percentile.
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);//from w w w. j a va 2 s. c om 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); }