Question

Im guessing PutMetricAlarm is the solution. http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html

I tried this:

Dimension instance = new Dimension();
instance.Name = "InstanceId";
instance.Value = "<i-02e1d855>";
PutMetricAlarmRequest sample =new PutMetricAlarmRequest();
sample.Dimensions.Add(instance);
sample.AlarmName = "SSample";
sample.ComparisonOperator = "LessThanThreshold";
sample.Threshold = .10;
sample.Statistic = "Average";
sample.Period = 300;
sample.EvaluationPeriods = 3;
sample.MetricName = "Metric Name";
sample.Namespace = "name space";
sample.Unit="Percent";
PutMetricAlarmResponse sampleres = cloudwatch.PutMetricAlarm(sample);

but nothing happens. did I do something wrong? and how can I add AlarmActions? that will terminate my instance when alarm triggers.

Please help. thanks

thanks.

No correct solution

OTHER TIPS

you have to add these two lines

PutMetricAlarmRequest alarmreq=new PutMetricAlarmRequest()
    .withActionsEnabled(true)
    .withAlarmActions("arn:aws:automate:us-east-1:ec2:stop");

//This stops the instance in the requests

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top