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

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

Introduction

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

Prototype


public void setMetricName(String metricName) 

Source Link

Document

The name for the metric associated with the alarm.

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);//from w  w  w .  j a v a 2s .com
    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);
}