Atatus Database Monitoring provides deep visibility into your MongoDB databases by collecting key performance metrics, slow operations, query samples, explain plans, and replication health.
To enable MongoDB monitoring, the Atatus Infra Agent must be installed and configured to connect directly to your MongoDB instance. This guide walks you through the required prerequisites and setup process for self-hosted MongoDB environments.
Before You Begin
| Component | Supported Versions |
|---|---|
| MongoDB | 4.4, 5.0, 6.0, 7.0, 8.0 |
| MongoDB Editions | Community, Enterprise |
| Atatus Infra Agent | 4.1.0 or higher |
To enable MongoDB Database Monitoring with Atatus, complete the following steps:
Grant the Agent access to your MongoDB instances
Connect to the MongoDB shell, authenticate to the standalone instance, and create a read-only Atatus user in the admin database with required permissions.
1. Connect to your MongoDB shell and switch to the admin database:
use admin
db.auth("admin", "<YOUR_ADMIN_PASSWORD>")
2. Create a read-only user for Atatus:
db.createUser({
"user": "atatus",
"pwd": "<STRONG_PASSWORD>",
"roles": [
{ role: "read", db: "admin" },
{ role: "read", db: "local" },
{ role: "clusterMonitor", db: "admin" }
]
})
Grant additional database monitoring permissions to the Atatus Agent user (Optional)
db.grantRolesToUser("atatus", [
{ role: "read", db: "<DB_NAME>" },
{ role: "read", db: "<DB_NAME>" }
])
For monitoring all databases, grant the readAnyDatabase role (Optional)
db.grantRolesToUser("atatus", [
{ role: "readAnyDatabase", db: "admin" }
])
Connect to the primary node, authenticate, and create a read-only Atatus user in the admin database with required permissions.
1. Connect to your MongoDB shell and switch to the admin database:
use admin
db.auth("admin", "<YOUR_ADMIN_PASSWORD>")
2. Create a read-only user for Atatus:
db.createUser({
"user": "atatus",
"pwd": "<STRONG_PASSWORD>",
"roles": [
{ role: "read", db: "admin" },
{ role: "read", db: "local" },
{ role: "clusterMonitor", db: "admin" }
]
})
Grant additional database monitoring permissions to the Atatus Agent user (Optional)
db.grantRolesToUser("atatus", [
{ role: "read", db: "<DB_NAME>" },
{ role: "read", db: "<DB_NAME>" }
])
For monitoring all databases, grant the readAnyDatabase role (Optional)
db.grantRolesToUser("atatus", [
{ role: "readAnyDatabase", db: "admin" }
])
Configure Atatus Infra Agent
To enable Atatus monitoring for a standalone MongoDB instance, update the configuration file by adding the following configuration to /etc/atatus-infra-agent/conf.d/mongodb.d/mongodb.yml:
metrics:
- hosts: ["localhost:27017"]
username: atatus
password: <REPLACE_PASSWORD>
connection_scheme: "mongodb"
db_name: "admin"
options:
connectTimeoutMS: 3000
serverSelectionTimeoutMS: 2000
dbm: true
cluster_name: <CLUSTER_NAME>
Note: Replace <STRONG_PASSWORD> with the password you created for the Atatus user.
To monitor a MongoDB replica set, the Agent must connect to all replica set members, including the arbiter.
Update the configuration file by adding the following configuration to
/etc/atatus-infra-agent/conf.d/mongodb.d/mongodb.yml.
metrics:
- hosts:
- <HOST_REPLICA_1>:<PORT> # Primary node
username: atatus
password: <REPLACE_PASSWORD>
connection_scheme: "mongodb"
db_name: "admin"
options:
connectTimeoutMS: 3000
serverSelectionTimeoutMS: 2000
dbm: true
cluster_name: <CLUSTER_NAME>
- hosts:
- <HOST_REPLICA_2>:<PORT> # Secondary node
username: atatus
password: <REPLACE_PASSWORD>
connection_scheme: "mongodb"
db_name: "admin"
options:
connectTimeoutMS: 3000
serverSelectionTimeoutMS: 2000
dbm: true
cluster_name: <CLUSTER_NAME>
Note: Replace <REPLICA_SET_NAME> with your replica set name and <STRONG_PASSWORD> with the password you created for the Atatus user.
Restart the Atatus Infra Agent to apply the changes:
sudo service atatus-infra-agent restart
Restart the Atatus Infra Agent to apply the changes:
sudo service atatus-infra-agent restart
+1-415-800-4104