> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Oplog Access

**Note:**

This page applies to Atlas Infinite clusters and Atlas Core clusters. On an Atlas Infinite cluster, you can read the oplog collection as described on this page, but you can't set an oplog size. The collection serves [change streams](https://www.mongodb.com/docs/manual/changeStreams.md#std-label-changeStreams) and some internal functions rather than replication, which the storage layer handles. To learn how the oplog behaves on an Atlas Infinite cluster, see [Oplog on Atlas Infinite clusters.](https://www.mongodb.com/docs/atlas/infinite/atlas-infinite-architecture.md#std-label-atlas-infinite-oplog)

The [oplog](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-oplog), a special [capped collection](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-capped-collection), records operations that modify the data stored in your databases.

You must precede a [`$regex`](https://www.mongodb.com/docs/manual/reference/operator/query/regex.md#mongodb-query-op.-regex) query on an [oplog](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-oplog) in a Free cluster or a Flex cluster with a carat (`^`). Otherwise, the following error occurs:

```sh
MongoServerError: Oplog ns RegEx queries must begin with ^
```

## Add a User with Oplog Access

To access the oplog, a database user must have read access on the `local` database. To create a user with read access on `local`:

1. In Atlas, go to the Database & Network Access page for your project.

   If it's not already displayed, select the organization that contains your project from the  Organizations menu in the navigation bar.

   If it's not already displayed, select your project from the Projects menu in the navigation bar.

   In the sidebar, click Database & Network Access under the Security heading.

   The [Database & Network Access](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fsecurity%2Fdatabase) page displays after you complete the preceding steps.

2. Add a user.

   It it's not already displayed, click the Database Users tab.

   Click  Add New Database User and enter a user name such as `oploguser`.

   Click Grant Specific Privileges and select the `read` role and the `local` database. This restricts the user to read operations on the `local` database.

   Enter a password and click Add User.

## Access the Oplog

1. [Connect to your cluster](https://www.mongodb.com/docs/atlas/mongo-shell-connection.md#std-label-connect-mongo-shell) with the [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh), using the credentials of the new database user with access to the `local` database.

2. Switch to the `local` database.

   ```none
   > use local
   ```

3. The oplog collection is named `oplog.rs`. Database write operations are recorded in date order, with a [timestamp](https://www.mongodb.com/docs/manual/reference/bson-types/#timestamps) field and a wall clock field.

   The timestamp field contains an integer with [seconds since epoch.](https://en.wikipedia.org/wiki/Unix_time)

**Note:**

- To increase the size of an oplog for a cluster, see [Set Oplog Size.](https://www.mongodb.com/docs/atlas/cluster-additional-settings.md#std-label-set-oplog-size)

- You can't use the MongoDB command [replSetResizeOplog](https://www.mongodb.com/docs/atlas/unsupported-commands.md#std-label-paid-tier-command-limitations) to resize the oplog.
