MongoDB Integration
The MongoDB integration ingests performance and health metrics from your MongoDB instances into Middleware. This way, you can track connections, operations, index/storage usage, network I/O, locks, and more in dashboards and alerts.
Prerequisites
The Middleware Host Agent must be installed on the host that can reach your MongoDB instance(s). If you haven't installed it yet, follow the Middleware Installation Guide first.
MongoDB Profiling Setup
Before configuring the Middleware integration, you need to set up MongoDB profiling to enable query performance monitoring.
Create a user with profiling permissions
Create a user in the admin database with profiling permissions:
1use admin
2db.createUser({
3 user: "otelProfiler",
4 pwd: "StrongPasswordHere",
5 roles: [
6 { role: "dbAdminAnyDatabase", db: "admin" }, // can manage profiling in all DBs
7 { role: "clusterMonitor", db: "admin" } // can read monitoring info
8 ]
9})Test the profiling setup
Log in with the new user and test the profiling configuration:
1mongo -u otelProfiler -p StrongPasswordHere --authenticationDatabase adminOnce connected, test profiling on a database:
1use mydb
2db.setProfilingLevel(2) // enables full profiling
3db.getProfilingStatus()If profiling is enabled correctly, you should see output similar to this:
1testdb> db.getProfilingStatus()
2{ was: 2, slowms: 1, sampleRate: 1, ok: 1 }Setup
1 Create database credentials (YAML)
Create a credentials file on the host running the Middleware Host Agent. If your database is not password-protected, you may omit the username and password fields. Docker users should create this file under /var/log. Example: /home/ubuntu/mongodb-creds.yaml
1mongodb:
2 hosts:
3 - endpoint: localhost:27017
4 username: mongodb
5 password: mongodb
6 profiling_level: 1
7 slow_ms: 10Here:
profiling_levelcontrols MongoDB profiler behavior:0disables profiling,1profiles queries slower thanslow_ms(ms),2profiles all queries.slow_msis only used whenprofiling_levelis1.
Config Attributes:
| Attribute | Description |
|---|---|
endpoint | Endpoint for MongoDB connection. Required. |
username | Username for MongoDB connection. Required if your DB requires auth. |
password | Password for MongoDB connection. Required if your DB requires auth. |
profiling_level | Profiler level: 0, 1, or 2. 0 disables profiling; 1 uses slow_ms; 2 profiles all queries. Optional. |
slow_ms | Slow-query threshold in ms (used only when profiling_level: 1). Optional. |
Tip: Keep this file readable by the agent only (e.g., restrict filesystem permissions) and ensure the host can reach the MongoDB endpoint. (The official doc calls out the fields and their meanings; this tip simply makes the usage explicit.)
2 Open the integration in Middleware
In the Middleware app, go to Installations → All Integrations → MongoDB. This opens the MongoDB integration form.

3 Enable the integration
In the MongoDB integration form:
- Add/Select the host (the one where you created the YAML).
- Paste the credentials file path from Step 1.
- Click Save.

After saving, the integration begins ingesting metrics; a default dashboard will appear (give it a few minutes if you’ve just connected).
Visualize Analytics
Default MongoDB Dashboard
Once the integration is enabled, a MongoDB dashboard is added under Dashboard Builder. Use it to validate the setup and start exploring key metrics without building widgets from scratch.
Create a Custom MongoDB Widget
When creating a new dashboard widget, select the mongodb data source to browse the full list of MongoDB metrics and build charts aligned to your SLOs.
Alerts
You can alert on any MongoDB metric. Create a rule with 'Database' as the detection method and 'MongoDB' as the database type; the 'Metrics' dropdown will list all MongoDB metrics. Choose your metric, set conditions/thresholds, and add recipients.
Metrics Collected
Inventory & Storage
| Metric Name | Description |
|---|---|
mongodb.database.count | Number of existing databases |
mongodb.collection.count | Number of collections |
mongodb.object.count | Number of objects |
mongodb.data.size | Size of the collection; data compression does not affect this value |
mongodb.storage.size | Total amount of storage allocated to this collection |
mongodb.index.count | Number of indexes |
mongodb.index.size | Total space allocated to all database indexes, including free index space |
mongodb.extent.count | Number of extents |
Connections, Sessions & Cursors
| Metric Name | Description |
|---|---|
mongodb.connection.count | Number of connections |
mongodb.session.count | Total number of active sessions |
mongodb.cursor.count | Number of opened cursors maintained for clients |
mongodb.cursor.timeout.count | Number of cursors that have timed out |
Operations & Profiling
| Metric Name | Description |
|---|---|
mongodb.operation.count | Number of operations executed |
mongodb.operation.repl.count | Number of replicated operations executed |
mongodb.document.operation.count | Number of document operations executed |
mongodb.operation.time | Total time spent performing operations |
mongodb.operation.latency.time | Total latency of operations |
Index Usage
| Metric Name | Description |
|---|---|
mongodb.index.access.count | Number of times an index has been accessed |
Network
| Metric Name | Description |
|---|---|
mongodb.network.io.receive | Number of bytes received |
mongodb.network.io.transmit | Number of bytes transmitted |
mongodb.network.request.count | Number of requests received by a server |
Locks & Concurrency
| Metric Name | Description |
|---|---|
mongodb.global_lock.time | Total time the global lock has been held |
mongodb.lock.acquire.count | Number of times a lock was acquired in the specified mode |
mongodb.lock.acquire.wait_count | Number of times lock acquisitions encountered waits due to locks held in conflicting modes |
mongodb.lock.acquire.time | Cumulative wait time for the lock acquisitions |
mongodb.lock.deadlock.count | Number of times lock acquisitions encountered deadlocks |
Cache & Memory
| Metric Name | Description |
|---|---|
mongodb.cache.operations | Number of cache operations |
mongodb.memory.usage | Amount of memory used |
Health & Uptime
| Metric Name | Description |
|---|---|
mongodb.health | Health status of the server |
mongodb.uptime | Amount of time the server has been running |
Troubleshooting
“Integrations” menu not visible
If Integrations isn’t visible in Middleware, your user role likely lacks Installation permissions. Ask an administrator to add Installation permission to your role in Settings.
Need assistance or want to learn more about Middleware? Contact our support team at [email protected] or join our Slack channel.