Monitoring AWS DMS Tasks with EventBridge

Last Updated:

Monitoring the state of AWS Database Migration Service (DMS) tasks is crucial for maintaining the reliability and efficiency of database migrations. Timely notifications on task status changes, especially failures, are essential. This article guides you through setting up AWS EventBridge rules to trigger SNS topic notifications upon DMS task state changes, ensuring prompt awareness of your task statuses.

Setting Up EventBridge Rules

To start, access the AWS Console and navigate to Amazon EventBridge > Buses > Rules. Here, you’ll create a new rule to detect DMS task state changes. The basic event pattern is as follows:

{
  "source": ["aws.dms"],
  "detail-type": ["DMS Replication Task State Change"]
}

This configuration triggers an event for any status change in DMS tasks.

This event will get triggered if any of the DMS tasks fail. For example, If the status changes from “Running” to “Failed”, this event will get triggered. This may not be what you want as even triggers have some charges.

You can specify a Resource ARN for the event pattern filter so that the event is only triggered if that specific task status is changed.

{
  "source": ["aws.dms"],
  "detail-type": ["DMS Replication Task State Change"],
  "resources": ["arn:aws:dms:region:account-id:task:task-id"]
}

Replace the resource ARN with your task resource ARN.

Configuring SNS Topic as Target

After setting the event pattern, choose an SNS topic under ‘targets’. Create a new SNS topic in the Simple Notification Service console if you haven’t already.

For creating the SNS topic, go to Simple Notification Service > Topics > Create topic > Give it a name > Create.

SNS topic is not the only target of course as many other services can be used as a target for the EventBridge Rule.

Subscribing to Notifications

Upon creating the SNS topic, subscribe to it for direct notifications whenever your DMS task’s status changes.

To subscribe to the SNS topic you created earlier, go to AWS SNS service > Topics > Click on the topic you created > Create subscription.

That way, you will receive a notification whenever there is a status change to the DMS task.

Testing Your Setup

To verify your configuration, temporarily stop the DMS task and observe if an event triggers in EventBridge and results in a notification.

Below is a sample event structure sent to the SNS topic:

{
    "version": "0",
    "id": "76e394j4-b83f-abvr-dfgh-xydfk32",
    "detail-type": "DMS Replication Task State Change",
    "source": "aws.dms",
    "account": "123456789",
    "time": "2023-12-18T12:12:43Z",
    "region": "us-east-1",
    "resources": [
        "arn:aws:dms:us-east-1:xxxx:task:task-id"
    ],
    "detail": {
        "eventId": "DMS-EVENT-0039",
        "eventType": "REPLICATION_TASK_STARTED",
        "detailMessage": "Replication task started, with flag, resume",
        "type": "REPLICATION_TASK",
        "category": "StateChange"
    }
}

Conclusion

In this blog, we covered how to configure events for state change of our Database Migration Service (DMS) Tasks. We created the event on EventBridge and created an SNS topic as a target for this even when it gets triggered.

For comprehensive monitoring of your DMS instance, refer to AWS’s official documentation and blog posts for advanced setups and best practices.

Setting up Amazon CloudWatch alarms for AWS DMS resources using the AWS CLI

Monitoring AWS DMS tasks.

RECENT POSTS

Get Ops Pro Tips in Your Inbox!