MongoDB

In this section, we will go over how to gather your credentials and prepare your MongoDB server to start providing CDC logs.

Introduction

We will be running Debezium to fetch CDC logs from MongoDB by using Change Streams which is a more performant and reliable approach than tailing the oplog.

MongoDB server must be in a replica set. If your deployment only has a standalone server, you can create a replica set with one member.

Need help? Check out this guide.

Finding your MongoDB settings

This is necessary so that we are able to run a Debezium deployment to subscribe to Change Events within your MongoDB cluster. To see additional configuration properties, please click here to see Debezium's documentation.

Creating a service account

You can either use the Atlas UI or use MongoDB CLI.

Option #1 - Atlas UI

  • Click on "Database Access" on the left

  • Click on "Add New Database User"

  • Under "Database User Privileges", open "Built-in Role" and Select "Only read any database"

Option #2 - Service account script

# If the user does not exist.
use admin;
db.createUser({
    user: "robin1",
    pwd: "<password>",
    roles: ["readAnyDatabase", {
        role: "read",
        db: "local"
    }]
});

# If the user already exists
db.updateUser("robin1", {
    roles: ["readAnyDatabase", {
        role: "read",
        db: "local"
    }]
});

Connection string

  1. Go to Atlas UI

  2. Find your deployment and click "Connect"

We support both MongoDB SRV format or standard connection string.

Supported types

Types are sourced from the MongoDB extended JSON specification.

  • Array

  • Binary

  • Array

  • Boolean

  • ObjectID

  • Int32

  • Int64

  • Double

  • Decimal128

  • Code

  • CodeWScope

  • RegEx

  • Datetime

  • Timestamp

  • String

Running it yourself

Self-hosted notes:

Last updated