I want to be notified when my Amazon EMR cluster or step changes state. How can I accomplish this with Amazon CloudWatch?
CloudWatch doesn't have metrics for monitoring Amazon EMR step or cluster state changes. This means that you can't use CloudWatch alarms to monitor cluster state changes. However, you can use CloudWatch Events to accomplish this task.
When you create a CloudWatch event, you choose a target, such as an Amazon Simple Notification Service (Amazon SNS) topic. The target is triggered when a specified event occurs, such as when a cluster state changes. For more information about the Amazon EMR events that you can use to create a CloudWatch event, see Monitor CloudWatch Events.
To create a CloudWatch Events rule that sends an SNS message when an Amazon EMR cluster or step changes state:
1. Create an SNS topic. This topic is the target for the CloudWatch Events rule.
2. Open the AWS Identity and Access Management (IAM) console, and then choose Roles in the navigation pane.
3. Choose the name of the role that is attached to your cluster's Amazon Elastic Compute Cloud (Amazon EC2) instances (for example, EMR_EC2_DefaultRole).
4. Choose Attach policies.
5. Attach the AmazonSNSFullAccess policy to the role. This policy allows SNS to send notifications based on state changes in your Amazon EMR cluster.
6. Follow the steps for Creating a CloudWatch Events Rule That Triggers on an Event.
For Service Name, choose EMR.
For Event Type, choose State Change.
For Targets, select SNS topic, and then choose the topic that you created in step 1.
Note: You can choose more than one target per rule. For example, you can perform an AWS Lambda function, send an SNS notification, and send a message to an Amazon Simple Queue Service (Amazon SQS) queue at the same time, in the same rule.
If the CloudWatch Events rule doesn't behave as expected, see Troubleshooting CloudWatch Events.