Monitoring MongoDB
The MongoDB sensor is automatically deployed and installed after you install the Instana agent.
Support information
To make sure that the MongoDB sensor is compatible with your current setup, check the following support information sections:
Supported operating systems
The sensor supports the same operating systems as the Instana host agents. For details, refer to the Supported Operating Systems section for each host agent, such as:
- Supported operating systems for Unix
- Supported operating systems for Windows
- Supported operating systems for Linux
Supported versions and support policy
The sensor supports the following MongoDB and MongoDB Atlas versions:
- MongoDB 3.2.x
- MongoDB 3.4.x
- MongoDB 3.6.x
- MongoDB 4.0.x
- MongoDB and MongoDB Atlas 4.2.x
- MongoDB and MongoDB Atlas 4.4.x
- MongoDB and MongoDB Atlas 5.0.x
- MongoDB and MongoDB Atlas 6.0.x
- MongoDB and MongoDB Atlas 7.0.x
- MongoDB and MongoDB Atlas 8.0.4
The following table shows the latest supported version and support policy:
| Technology | Support policy | Latest technology version | Latest supported version |
|---|---|---|---|
| MongoDB | 45 days | 8.3.4 | 8.3.3 |
| MongoDB Atlas | 45 days | 8.3.4 | 8.2.7 |
For more information about the support policy, see Support strategy for sensors.
Supported client-side tracing
Configuration
MongoDB with disabled authentication
No actions are required. Monitoring of MongoDB with disabled authentication happens automatically without providing any configurations in the configuration.yaml file.
MongoDB with enabled authentication
To monitor MongoDB, you need to create a user with the following minimum roles:
-
read- onadmindatabase -
clusterMonitoer- onadmindatabase -
read- onlocaldatabase
In a mongo shell, create a user for the Instana Agent in the admin database:
- Authenticate as the
adminuser:use admin db.auth("admin", "YOUR_MONGODB_ADMIN_PASSWORD") - For MongoDB 3.x and later versions, run the
createUsercommand:db.createUser({ "user":"stan", "pwd": "UNIQUEPASSWORD", "roles" : [ {role: 'read', db: 'admin' }, {role: 'clusterMonitor', db: 'admin'}, {role: 'read', db: 'local' } ] })Note: If you use MongoDB Atlas, create the user with all assigned roles through the MongoDB Atlas management console only. -
After the user is created, you can configure it in the agent configuration file:
com.instana.plugin.mongodb: user: 'stan' source: 'admin' password: 'UNIQUEPASSWORD' poll_rate: general_metrics: 1 # general MongoDB metrics (connections, ops, etc.) replicaset_metrics: 30 # replica set state metrics host: '' # Optional: Explicit hostname or fully qualified domain name (FQDN) for MongoDB connection (for example, 'mongodb.example.com'). If not specified, the first hostname from the MongoDB bindIp configuration is used.Note: The default value for the general metrics interval is 1 second, and the replica set interval is 30 seconds.Thesourcerefers to the database or authentication source where the user is defined. For more information, see the MongoDB documentation .Note: When you monitor a MongoDB cluster or standalone instance with Instana, configure--bind_ipwith specific IP addresses or leave it unset to use the default value 127.0.0.1. Do not use thebind_ip_allparameter.
MongoDB Atlas support
The Instana agent supports remote monitoring of MongoDB Atlas clusters in different projects and organizations. For the Instana agent to be able to monitor your MongoDB Atlas organizations, it needs to be configured here <agent_install_dir>/etc/instana/configuration.yaml:
com.instana.plugin.mongodb:
user: 'stan'
source: 'admin'
password: 'UNIQUEPASSWORD'
poll_rate:
general_metrics: 1 # general MongoDB metrics (connections, ops, etc.)
replicaset_metrics: 30 # replica set state metrics
atlas:
- publicKey: 'your public key'
privateKey: 'your private key'
- publicKey: 'your public key'
privateKey: 'your private key'
Organization Read Only. SSL/TLS support
For the Instana agent to securely connect to your MongoDB server, it needs to be configured here <agent_install_dir>/etc/instana/configuration.yaml:
com.instana.plugin.mongodb:
...
sslTrustStore: '/path/to/truststore.jks'
sslTrustStorePassword: 'mongoTsPassword'
sslKeyStore: '/path/to/sslKeyStoreFile.jks'
sslKeyStorePassword: 'mongoKsPassword'
To enable the SSL/TLS support feature, keys must be in the Java Keystore format (JKS). The keytool can be used to create these keys.
Metrics collection
To view metrics, select Infrastructure in the Instana user interface sidebar, click a monitored host, and view the host dashboard with all collected metrics and monitored processes.
Configuration data
- Version
- Port
- Storage engine
- Databases
- Node Type: For sharded clusters, identifies the instance as
mongos,config_server, orshard_server - Config DB Connection String: Available for
mongosinstances only
Performance metrics
Database activity
| Metric | Description |
|---|---|
| Read | Number of documents read |
| Inserted | Number of documents inserted |
| Uploaded | Number of documents uploaded |
| Deleted | Number of documents deleted |
Opcounters
| Metric | Description |
|---|---|
| Update | Total number of update operations that are received after the mongod instance last started. |
| Insert | Total number of insert operations that are received after the mongod instance last started. |
| Query | Total number of queries that are received after the mongod instance last started. |
| Delete | Total number of the delete operations after the mongod instance last started. |
| getMore | Total number of the getMore operations after the mongod instance last started. |
Memory
| Metric | Description |
|---|---|
| Virtual | Virtual memory for the entire MongoDB process. If journaling is enabled, this value is typically twice the size of your mapped memory. |
| Mapped | Amount of virtual memory used by the MongoDB process to map your database into memory. This value is typically the size of your database. |
Clients
| Metric | Description |
|---|---|
| Connections | Number of current active clients that are connected to MongoDB server. |
| ActiveClients writers | Number of active client connections that perform write operations. |
| ActiveClients readers | Number of the active client connections that perform read operations. |
Databases (per database)
| Metric | Description |
|---|---|
| Database Size | Database size |
Replica Set (if exists)
| Metric | Description |
|---|---|
| Apply Ops | Number of internal apply operations |
| Apply batches | Number of internal apply batches |
| Apply batches total (ms) | Duration of apply batches in milliseconds |
| Buffer count | Number of buffers |
| Buffer size | Buffer size |
| Network Ops | Number of network operations |
| Network bytes | Size of network operations |
| Preload docs | Number of preload docs operation |
| Preload docs total (ms) | Duration of preload docs in milliseconds |
| Preload Idx | Number of preload idx operation |
| Preload Idx total (ms) | Duration of preload idx in milliseconds |
| Replication lag | Delay between a write operation on the primary and its copy to a secondary (milliseconds) |
Atlas Cluster (if exists)
| Metric | Description |
|---|---|
| Read | Number of documents read |
| Inserted | Number of documents inserted |
| Uploaded | Number of documents uploaded |
| Deleted | Number of documents deleted |
| Connections | Number of clients currently connected |
| Network Ops | Number of network operations |
| Network Bytes | Size of network operations |
Sharded cluster (mongos and config servers)
For MongoDB sharded clusters, Instana monitors both mongos router instances and config servers to track cluster health and connectivity.
Mongos metrics (if exists)
Mongos configuration data
The following configuration information is collected for mongos instances:
| Configuration item | Description |
|---|---|
| Version | MongoDB version running on the mongos instance |
| Port | Port number the mongos instance is listening on |
| Storage engine | Storage engine used by the mongos instance |
| Node type | Type of MongoDB node (mongos for router instances) |
| Config DB | Connection string for the config server replica set |
The following metrics are available in the mongos dashboard:
| Metric category | Metrics | Description |
|---|---|---|
| Connections | Connections | Number of active clients connected to mongos |
| Database size | Total database size | Total size of all databases accessible through mongos |
| Database activity | Read, Inserted, Updated, Deleted | Number of documents read, inserted, updated, and deleted |
| Clients | Connections | Active client connections |
| Memory | Virtual, Mapped | Virtual and mapped memory usage by the mongos process |
| Read requests per second | Query, Get more | Number of query and getMore operations per second |
| Write requests per second | Insert, Update, Deleted | Number of insert, update, and delete operations per second |
| Number of clients with read operations | Active clients readers, Available connections | Active read clients and available connections in the pool |
| Number of clients with write operations | Active clients writers, Connections in use | Active write clients and connections currently in use |
| Databases | Name, Size | List of all databases accessible through this mongos instance |
Config server metrics (if exists)
Config server configuration data
The following configuration information is collected for config servers:
| Configuration item | Description |
|---|---|
| Version | MongoDB version running on the config server |
| Port | Port number the config server is listening on |
| Storage engine | Storage engine used by the config server |
| Node type | Type of MongoDB node |
| Replica set name | Name of the config server replica set |
| Role | Current role of the node in the replica set |
Config servers are specialized mongod instances that store cluster metadata and configuration. They collect the same standard MongoDB metrics as regular mongod instances:
| Metric category | Metrics | Description |
|---|---|---|
| Connections | Connections | Number of active clients connected to mongod |
| Database size | Total database size | Total size of all databases accessible through mongod |
| Database activity | Read, Inserted, Updated, Deleted | Number of documents read, inserted, updated, and deleted |
| Clients | Connections | Active client connections |
| Memory | Virtual, Mapped | Virtual and mapped memory usage by the mongod process |
| Read requests per second | Query, Get more | Number of query and getMore operations per second |
| Write requests per second | Insert, Update, Deleted | Number of insert, update, and delete operations per second |
| Number of clients with read operations | Active clients readers, Available connections | Active read clients and available connections in the pool |
| Number of clients with write operations | Active clients writers, Connections in use | Active write clients and connections currently in use |
| Databases | Name, Size | List of all databases accessible through this mongod instance |
Config server replica set metrics (if exists)
Config servers are deployed as replica sets for high availability. The following replica set metrics are collected:
| Metric category | Metrics | Description |
|---|---|---|
| Database activity | Read, Inserted, Updated, Deleted | Number of documents read, inserted, updated, and deleted |
| Replication performance | Replication lag | Delay between write on primary and copy to secondary (ms) |
| Clients | Connections | Number of active client connections |
| Apply operations | Apply ops, Apply batches, Apply batches total | Internal apply operations, batches, and total duration (ms) |
| Network | Network ops, Network bytes | Number and size of network operations |
| Buffer | Buffer count, Buffer size | Number of buffers and buffer size |
| Preload | Documentation, Indexes, Documentation total, Indexes total | Preload operations for documents and indexes with total time (ms) |
Monitoring benefits
Sharded cluster monitoring provides visibility into the following areas:
- Mongos routers: Connection pool health and utilization for routing queries
- Config server availability: Critical for cluster metadata operations and configuration changes
- Shard connectivity and performance: Ensures data nodes are reachable and responsive
- Overall sharded cluster health: End-to-end monitoring of the distributed architecture
These metrics help ensure the following conditions:
- Mongos servers maintain active connections to config servers and shards
- Config servers are available and functioning correctly (critical for cluster operations)
- The sharded cluster infrastructure functions correctly across all nodes
- Query routing performance is optimal
- Potential connectivity issues are detected early before they affect applications
Health signatures
For each sensor, a curated knowledge base of health signatures is continuously evaluated against incoming metrics and used to raise issues or incidents depending on user impact.
Built-in events trigger issues or incidents based on failing health signatures on entities, and custom events trigger issues or incidents based on the thresholds of an individual metric of any given entity.
For information about built-events for the MongoDB sensor, see the Built-in events reference.For more information about MongoDB sharded clusters with mongos instances, see MongoDB sharded cluster (Mongos).