Integrate a MongoDB instance
The MongoDB integration component connects a self-managed MongoDB deployment to Cloud Monitor 2.0 and collects metrics for connections, operation throughput, replica set status, WiredTiger cache, memory, and database storage. Use it to monitor standalone nodes and replica sets in either the CS or the ECS (VPC) environment. After the integration is complete, MongoDB instance entities and built-in dashboards are generated automatically.
Requirements
The following table lists the MongoDB versions, deployment types, and connection behavior that the MongoDB integration component supports.
|
Condition |
Requirement |
|
Version |
MongoDB 4.4 or later. The upstream aio-exporter is more thoroughly validated for versions 6.0 or later. Older versions might work but have not been fully tested. |
|
Deployment type |
Self-managed single node or ReplicaSet. Cloud-hosted services, such as Alibaba Cloud MongoDB, can also be connected if they meet account and network requirements. For a ReplicaSet, specify the additional seed nodes and the ReplicaSet name. |
|
Monitoring account |
If authentication is enabled, the account must have the |
|
Connection method |
For a single node, the default is |
|
Network connectivity |
For a Container Service (CS) environment, the target MongoDB must be reachable from the selected ACK cluster network. For an ECS (VPC) environment, the vSwitch CIDR block of the managed agent must have access to the target ECS instance. In a ReplicaSet deployment, all members must be reachable. |
Prerequisites
-
Managed Service for Prometheus is activated.
-
For CS environments: The target ACK cluster is connected to Cloud Monitor 2.0 and is running. The target MongoDB service is accessible from within the cluster network.
-
For ECS (VPC) environments: The ECS instance that hosts the target MongoDB is selected, and the vSwitch CIDR block for the managed agent can access this ECS instance.
Billing
-
Billing is based solely on the volume of metric data generated in Billing overview.
Integration methods
Step 1: Create a monitoring account (if needed)
If access authentication (auth) is enabled for your instance, create a monitoring account with the clusterMonitor role. You can skip this step if authentication is not enabled.
use admin
db.createUser({
user: "exporter",
pwd: "<password>",
roles: [ { role: "clusterMonitor", db: "admin" } ]
})
|
Role |
Purpose |
|
clusterMonitor |
Reads diagnostic data such as serverStatus, replSetGetStatus, and dbStats. |
Step 2: Select an integration environment
This plugin supports two access environments: CS and ECS(VPC). These environments work differently. Select an environment based on where your MongoDB instance is deployed.
CS
-
The Exporter is installed in a specified ACK cluster, and the existing data collector in that cluster is reused to collect metrics.
-
The monitored object is the ACK cluster.
-
Network requirements: The target MongoDB service must be accessible from the cluster network. For example, the service can be located within the cluster or have a private IP address in a VPC that the cluster can access.
ECS (VPC)
-
A fully managed data collector is deployed based on the VPC information of the ECS instance where the target MongoDB service is deployed.
-
No processes are installed on the ECS instance.
-
The monitored object is the ECS instance.
-
Network requirements: The vSwitch CIDR block where the managed data collector resides must allow access to the target ECS instance. Security groups, Access Control Lists (ACLs), and other network rules must be configured to allow this access.
|
Environment |
Exporter deployment location |
Installs a process on the application server? |
Monitored object |
Network connectivity requirements |
|
CS |
User-specified ACK cluster |
No. The Exporter is deployed in the cluster and does not use the host resources of the business pod. |
ACK cluster |
The MongoDB service must be accessible from within the cluster network. |
|
ECS (VPC) |
Fully managed data collector deployed by the system based on the VPC. |
No. No processes are installed on the ECS instance. |
ECS instance |
The vSwitch CIDR block of the managed agent must have access to the target ECS instance. |
Step 3: Configure the integration
-
Log on to the Cloud Monitor console. Select a workspace, and in the navigation pane on the left, click Integration Center. On the Integration Center page, click MongoDB.
-
Select an access environment, either CS or ECS (VPC), and then select an Observation object from the drop-down list.
-
Configure the integration parameters and click OK.
Parameter
Required
Description
MongoDB service endpoint
Yes
The primary connection address. In a ReplicaSet scenario, this address is used as the first seed.
MongoDB service port
Yes
Default: 27017. This port is used for extra seeds if no port is specified for them.
Extra seed nodes (ReplicaSet)
No
Other members of the ReplicaSet, separated by commas. Use the
hostorhost:portformat.ReplicaSet name
No
If specified,
replicaSet=is added to the URI, and direct connection mode is disabled.Authentication DB
No
Default:
admin.Direct connection mode
No
Recommended for single-node deployments. This setting is ignored and automatically disabled if a ReplicaSet name or extra seeds are configured.
Cloud vendor / Deployment source
No
Writes to the
providerlabel. For self-hosted deployments, the value isself-hosted/mongodb.MongoDB username/password
No
Required if authentication is enabled. The account needs the
clusterMonitorrole.Metric collection interval (seconds)
Yes
Default: 15.
Custom tags
No
Extra labels to inject into metrics.
Use public image repository address
No
Disabled by default. Enable this option if the internal image repository is inaccessible.
-
After the integration is successful, you can find the integrated entities and their observable data in Entity Explorer.
Data usage
Entities
After integration, Cloud Monitor periodically discovers MongoDB instances from the labels of metrics such as mongodb_up and creates middleware entities.
|
Dimension |
Description |
|
Domain |
middleware |
|
Entity type |
middleware.mongodb |
|
Entity filter condition |
|
|
Observed object (bound entity) |
|
Entity fields are derived from collected labels and are independent of the number of installations.
|
Field |
Description |
|
instance_id |
The instance identity. It is derived from the primary endpoint |
|
provider |
The deployment source, such as |
|
port |
The service port. |
|
region_id |
The region. |
|
env_type |
The deployment environment type (CS or ECS). |
|
cluster_id |
The ID of the cluster to which the instance belongs. |
You can retrieve instances using these fields in the Entity Explorer or Middleware Insight application.
Built-in dashboards
|
Dashboard name |
Access point |
Description |
|
MongoDB Overview (Instance Overview) |
The Instance Overview tab on the entity details page. |
A UModel dashboard. Variables are automatically bound based on the instance context. |
|
MongoDB Overview |
Grafana dashboard list |
A Grafana dashboard. Available in both Chinese and English. |
|
MongoDB Instance Details |
Grafana dashboard list |
A Grafana dashboard. Available in both Chinese and English. |
Core metrics
The following list contains all 30 metrics from the middleware.metric.mongodb entity dataset. You can use these metrics directly in entity details, dashboards, and alerts.
|
Metric name |
Type |
Unit |
Display name |
Description |
|
mongodb_up |
gauge |
- |
MongoDB Up |
Indicates whether the MongoDB instance is reachable. 1 means up, and 0 means unavailable. |
|
mongodb_uptime |
gauge |
seconds |
Uptime |
The uptime of the MongoDB service in seconds. |
|
mongodb_connections_current |
gauge |
- |
Current Connections |
The number of inbound connections that are currently open. |
|
mongodb_connections_available |
gauge |
- |
Available Connections |
The number of available inbound connections that are not yet used. |
|
mongodb_connections_active |
gauge |
- |
Active Connections |
The number of active client connections that are performing operations. |
|
mongodb_connections_created_rate |
counter |
count/s |
Connection Creation Rate |
The rate at which new inbound connections are created per second. |
|
mongodb_opcounters_rate |
counter |
count/s |
Operation Rate |
The rate of operations by type (insert, query, update, delete, getmore, or command). |
|
mongodb_opcounters_repl_rate |
counter |
count/s |
Replication Operation Rate |
The rate of replication operations by type. |
|
mongodb_op_latencies_latency |
counter |
- |
Operation Latency |
The per-second increase in cumulative operation latency by operation type (microseconds/second). |
|
mongodb_network_bytes_in |
counter |
bytes |
Inbound Network Traffic |
The number of bytes received by the network per second. |
|
mongodb_network_bytes_out |
counter |
bytes |
Outbound Network Traffic |
The number of bytes sent by the network per second. |
|
mongodb_network_num_requests |
counter |
count/s |
Network Requests |
The number of network requests received per second. |
|
mongodb_global_lock_current_queue |
gauge |
- |
Global Lock Wait Queue |
The number of operations in the global lock wait queue by type (readers, writers, or total). |
|
mongodb_global_lock_active_clients |
gauge |
- |
Global Lock Active Clients |
The total number of active clients that hold a global lock. |
|
mongodb_mem_resident |
gauge |
- |
Resident Memory |
The resident memory used by the MongoDB process in MB. |
|
mongodb_mem_virtual |
gauge |
- |
Virtual Memory |
The virtual memory used by the MongoDB process in MB. |
|
mongodb_wt_cache_used_bytes |
gauge |
bytes |
WiredTiger Cache Used |
The number of bytes currently stored in the WiredTiger cache. |
|
mongodb_wt_cache_dirty_bytes |
gauge |
bytes |
WiredTiger Cache Dirty Data |
The number of dirty bytes currently tracked in the WiredTiger cache. |
|
mongodb_wt_cache_max_bytes |
gauge |
bytes |
WiredTiger Cache Max Size |
The maximum configured size of the WiredTiger cache in bytes. |
|
mongodb_metrics_document_rate |
counter |
count/s |
Document Operation Rate |
The rate of document operations by type (inserted, updated, deleted, or returned). |
|
mongodb_cursor_open |
gauge |
- |
Open Cursors |
The number of cursors that are currently open. |
|
mongodb_cursor_timed_out_rate |
counter |
count/s |
Cursor Timeout Rate |
The number of cursors that time out and are closed per second. |
|
mongodb_asserts_rate |
counter |
count/s |
Assertion Rate |
The rate of assertions by type (regular, warning, msg, user, or rollovers). |
|
mongodb_page_faults_rate |
counter |
count/s |
Page Faults |
The number of page faults that occur per second in the MongoDB process. |
|
mongodb_dbstats_data_size |
gauge |
bytes |
Database Data Size |
The size of uncompressed data stored in each database in bytes. |
|
mongodb_dbstats_index_size |
gauge |
bytes |
Database Index Size |
The total size of indexes for each database in bytes. |
|
mongodb_dbstats_collections |
gauge |
- |
Database Collections |
The number of collections in each database. |
|
mongodb_dbstats_objects |
gauge |
- |
Number of database objects |
The number of objects (documents) in each database. |
|
mongodb_rs_members_health |
gauge |
- |
Replica Set Member Health |
The health status of a replica set member. 1 means healthy, and 0 means unreachable. |
|
mongodb_rs_members_state |
gauge |
- |
Replica Set Member State |
The state of a replica set member. 1 means PRIMARY, 2 means SECONDARY, and other values indicate transient states. |
In addition to the aggregated MetricSet metrics, the raw metrics collected by the exporter (mongodb_*) are written to Prometheus storage. You can query them directly using Prometheus Query Language (PromQL).
Common query examples
# Up
mongodb_up
# Current connections
mongodb_connections{state="current"}
# Operation rate (by type)
rate(mongodb_op_counters_total[5m])
Alert templates
This integration component does not have built-in alert rules. You can configure alerts in the Alert Center based on the metrics. For example, you can set an alert for scenarios where the mongodb_up metric is not 1, or when the number of connections or message accumulation exceeds a threshold.
Storage policies
After you integrate MongoDB, Cloud Monitor creates a corresponding storage instance to store observable data.
|
Data type |
Default storage location |
Notes |
|
Metrics |
Prometheus instance: RegionShare:{{workspaceName}}:{{regionId}} |
Associated dataset: |
Manage or remove the integration
To modify or cancel the integration, go to the Integration Management page of Integration Center, find the corresponding integration policy, and then click Edit or Delete. When you delete the integration policy, the Exporter and the collection configuration are removed together. Historical metrics that have already been written are retained based on the lifecycle policy of the storage.