Reputation: 882
I am looking to get a notification schema setup for my EC2 instances that are in the us-west-2 data center. I have read the CloudWatch and SNS docs, and I am aware that SMS notifications are only available when setting up SNS Topics in us-east-1.
I am wondering if anyone has found a way to get CloudWatch alarms for instances NOT in us-east-1 to broadcast on a topic setup in us-east-1?
Upvotes: 6
Views: 3340
Reputation: 11
This isn't exactly what you asked for, but I have instances in the us-west-1 region that I needed SMS alerts for, so I found a way to get this to work. The trick is to create both the metrics and the alerts in the us-east-1 region.
On your instance in the us-west-1 region, run the following command to create a metric in the us-east-1 region and and publish a value to it.
aws cloudwatch put-metric-data
--region us-east-1 --namespace NameSpace --metric-name MetricName
--dimensions InstanceId=i-12345678 --value 10
Next, in the us-east-1 region, create an SNS topic, along with associated SMS subscription(s).
Finally, in the us-east-1 region, the topic you created will be visible. create an alarm based on that metric, specifying the SNS topic you just created.
This alarm will now send SMS notifications via SNS when triggered.
I had thought there might be an additional cost of sending the metric data from us-west-1 to us-east-1, but it turns out that the cost is zero for the number of metrics and frequency I used, which was a single metric sent once per minute.
Upvotes: 1
Reputation: 31
If you're trying to create alarms in a region other than your default you must explicitly specify it with the --region option (despite this already being implicit in the ARN).
Upvotes: 1
Reputation: 2127
It appears that the documentation is incorrect - when trying to add a new alarm in us-west-2 that points at a topic in us-east-1 for the SMS capabilities, the following error is observed (tried this today on Sept 10 2014):
A client error (ValidationError) occurred when calling the PutMetricAlarm operation: Invalid region us-east-1 specified. Only us-west-2 is supported.
This is based on running the following command using the aws cli (account number changed to 1234567890):
aws cloudwatch put-metric-alarm --alarm-name "ELB UnHealthy > 0" --alarm-description "ELB UnHealthy > 0" --actions-enabled --ok-actions arn:aws:sns:us-west-2:1234567890:EmailOnly --alarm-actions arn:aws:sns:us-east-1:1234567890:EmailAndSMS --insufficient-data-actions arn:aws:sns:us-west-2:1234567890:EmailOnly --metric-name UnHealthyHostCount --namespace AWS/ELB --statistic Average --dimensions Name=LoadBalancerName,Value=elb-name --period 60 --evaluation-periods 3 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold
I guess the previous answer was from somebody who didn't actually test this out... It's that or AWS disabled the ability to reference other region sns topics in the last few months and forgot to update their documentation...
Upvotes: 7
Reputation: 1239
You can set up your alarms to send notifications to a different region with the Amazon Cloudwatch CLI. You just have to create the alarm in us-west-2 by calling mon-put-metric-alarm
and provide the ARN of your us-east-1 topic as alarm-actions
.
export AWS_CLOUDWATCH_URL=http://monitoring.us-west-2.amazonaws.com/
mon-put-metric-alarm --alarm-name my-alarm --alarm-description "some desc"
--metric-name CPUUtilization --namespace AWS/EC2
--statistic Average --period 60 --threshold 90
--comparison-operator GreaterThanThreshold
--dimensions InstanceId=i-abcdef --evaluation-periods 3 --unit Percent
--alarm-actions arn:aws:sns:us-east-1:1234567890:my-topic
You can read the official docs here:
http://docs.aws.amazon.com/AmazonCloudWatch/latest/cli/cli-mon-put-metric-alarm.html
And find CLI setup instructions here: http://docs.aws.amazon.com/AmazonCloudWatch/latest/cli/SetupCLI.html
Upvotes: 1