MongoDB
Added in v6.1.0 of DBmarlin
Pre-requisitesβ
Check the supported versionsβ
DBmarlin supports versions of MongoDB from 7.0 and above. Please check the list of supported platforms before continuing and contact us if you are not sure.
Create a monitoring user with the correct permissionsβ
Before adding a target MongoDB instance in the UI you should first create a dbmarlin user in the target database instance (you can choose to use a name other than dbmarlin if you prefer) and grant the required roles to that user.
db.getSiblingDB("admin").createRole("dbmarlinRole", {
privileges: [
// Read metadata from ALL normal databases
{
resource: { db: "", collection: "" },
actions: [
"find",
"listCollections",
"listIndexes",
"dbHash",
"collStats",
"dbStats",
"indexStats"
]
},
// Needed for system.profile
{
resource: { db: "", collection: "system.profile" },
actions: [ "find", "listIndexes", "collStats", "dbStats", "indexStats" ]
}
],
roles: [
// Needed for serverStatus, replSetGetStatus, listDatabases, etc
{ role: "clusterMonitor", db: "admin" },
// Required so listCollections/listIndexes work in every DB
{ role: "read", db: "local" }
]
})
db.getSiblingDB("admin").createUser({
user: "dbmarlin",
pwd: "securepassword",
roles: [
{ role: "dbmarlinRole", db: "admin" }
]
})
Enable profilingβ
You can set profiling on permanently (recommended), by editing the MongoDB configuration file and restarting the database instance. This give statement level metrics.
How to enable profilingβ
-
Edit the Configuration File
Open your MongoDB config file (usually
/etc/mongod.conf).operationProfiling:
mode: all
slowOpThresholdMs: 200 -
Restart the Database
sudo systemctl restart mongod -
Verify Itβs Enabled
db.getProfilingStatus()
Adding the Database Targetβ
This is done through the User Interface using the Add Database screen