Oplog Access
On this page
Important
Feature unavailable in Serverless Instances
Serverless instances don't support this feature at this time. To learn more, see Serverless Instance Limitations.
The oplog, a special capped collection, records operations that modify the data stored in your databases.
You must precede a $regex
query on an oplog in
an M0
Free cluster or M2/M5
Shared cluster with a
caret (^
). Otherwise, the following error occurs:
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
:
In Atlas, go to the Database 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 Access under the Security heading.
The Database Access page displays.
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 thelocal
database. This restricts the user to read operations on thelocal
database.Enter a password and click Add User.
Access the Oplog
Connect to your cluster with the
mongosh
, using the credentials of the new database user with access to thelocal
database.Switch to the
local
database.> use local The oplog collection is named
oplog.rs
. Database write operations are recorded in date order, with a timestamp field and a wall clock field.The timestamp field contains an integer with seconds since epoch.
Note
To increase the size of an oplog for a cluster, see Set Oplog Size.
You cannot use the MongoDB command replSetResizeOplog to resize the oplog.