Skip to main content

MongoDB

note

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​

  1. Edit the Configuration File

    Open your MongoDB config file (usually /etc/mongod.conf).

    operationProfiling:
    mode: all
    slowOpThresholdMs: 200
  2. Restart the Database

    sudo systemctl restart mongod
  3. Verify It’s Enabled

    db.getProfilingStatus()

Adding the Database Target​

This is done through the User Interface using the Add Database screen