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

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

Introduction

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

Prototype


public void setNamespace(String namespace) 

Source Link

Document

The namespace for the metric associated specified in MetricName.

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   www.j ava  2s  .  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);
}