Monitor MongoDB Databases

Introduction

This tutorial demonstrates how to view metrics for MongoDB Enterprise clusters. The Grafana instance, which is connected to the Logging Service pipeline, is used to provide the data visualization of the metrics. By collecting metrics with a monitoring system, such as Prometheus through the official MongoDB exporter, and visualizing them in a Grafana dashboard, you can instantly detect anomalies, set proactive alerts on SLA-critical thresholds, troubleshoot latency or contention issues, and plan capacity upgrades with data-driven confidence.

Overview

MongoDB offers a set of observable metrics that describe the following:

  • Server’s health and performance.

  • Replication state—from low‑level resource usage such as CPU, memory, disk I/O, and network.

  • Server‑wide counters such as connections, operations per second, cache hits, and page faults.

  • Detailed replica‑set statistics such as election timestamps, primary‑secondary lag, and write‑concern success rates.

  • Per‑command activity such as query, insert, update, delete, getMore, and lock counts.

MongoDB metrics turn raw runtime data into actionable insight, enabling reliable operations, faster incident resolution, and efficient resource utilization for any production deployment.

Metrics for MongoDB

The following metrics are offered to gauge the health of the MongoDB clusters.

CPU and Memory

Metric

Description

ionos_dbaas_mongodb_cpu_rate5m

An average CPU usage of the cluster over 5 minutes. It displays how much processor capacity the database is using. Monitor this metric to gauge if the CPU usage is operating closer to its resource limits.

ionos_dbaas_mongodb_memory_total_bytes

The maximum memory allocated values, measured in bytes. It refers to the fixed memory limit for the instance.

ionos_dbaas_mongodb_memory_available_bytes

The remaining free memory in the cluster, measured in bytes. A lower value indicates that the database has limited available memory.

Storage and Disk

Metric

Description

ionos_dbaas_mongodb_storage_total_bytes

The maximum storage capacity allocated values in bytes.

ionos_dbaas_mongodb_storage_available_bytes

The remaining free storage space in the cluster, measured in bytes. A lower value indicates that the database has limited available storage.

ionos_dbaas_mongodb_disk_io_time_weighted_seconds_rate5m

The average time the disk spends handling read or write operations. A higher value indicates that the disk is busy.

Connections and Health

Metric

Description

ionos_dbaas_mongodb_connections_count

The total number of active client connections to the cluster. If the value is near the maximum count, new connections may fail. Monitor connections to determine whether the current connection limits are sufficient.

ionos_dbaas_mongodb_health:

Indicates whether the cluster is healthy or not. If the value is 1, the cluster is considered healthy; if the value is 0, the cluster is considered unhealthy.

Query Patterns

Metric

Description

ionos_dbaas_mongodb_scan_and_order_rate5m

Scans and orders data using an in-memory sort. It is averaged over a 5-minute window. Monitor this metric to determine whether your queries need indexes.

Indexes

Metric

Description

ionos_dbaas_mongodb_index_count_total

The total number of indexes across collections. Monitor this metric to review unused indexes and free up memory and disk space.

ionos_dbaas_mongodb_index_size_bytes

The total disk size of all indexes in the database, measured in bytes. Monitor this metric to manage your indexes.

Cluster or Replica Set State

Metric

Description

ionos_dbaas_mongodb_instance_count

The total number of MongoDB instances, which together form a replica set. If the count is lower, then a node may be down.

ionos_dbaas_mongodb_member_state

The state of the replica set member. If the value is 1, it is in a PRIMARY state, and a value of 2 indicates it is in a SECONDARY state.

Replication or Oplog

Metric

Description

ionos_dbaas_mongodb_oplog_size_bytes

The size of the operations log, measured in bytes. It stores recent database changes, which act as a buffer to create replicas. Monitor this metric to ensure it is not smaller than the write activity, as this may lead to replication delays.

ionos_dbaas_mongodb_oplog_window_seconds

The time span of the operations logs up to where the replicas are possible. It is measured in seconds. Monitor this metric to ensure the operations log window is not too short, as this can cause replication to slow down.

ionos_dbaas_mongodb_replication_headroom_seconds

The maximum replication lag, measured in seconds, among all secondary members in a MongoDB replica set. This metric indicates how far behind the most delayed secondary is compared to the primary. Monitor this metric to keep replication lag minimal and ensure data consistency and reliable failover behavior across the replica set.

ionos_dbaas_mongodb_replication_lag_seconds

The delay between the primary and secondary copies of data is measured in seconds. Monitor this metric to spot any slow or unhealthy secondaries early on and ensure read‑consistency, and trigger alerts or scaling actions before replication delays affect application performance or data‑loss risk.

ionos_dbaas_mongodb_replication_last_election_timestamp_seconds

The time when the most recent primary election occurred in the MongoDB replica set, measured in seconds. Monitor this metric to detect unexpected failovers and trigger alerts or investigations before they impact application availability.

Top Operations (per 5m) Window

Metric

Description

ionos_dbaas_mongodb_top_commands_count

The number of active MongoDB command operations. Monitor this metric to spot workload spikes or long-running queries.

ionos_dbaas_mongodb_top_getmore_count

The number of active getMore operations on each MongoDB node. Monitor this metric to detect any heavy cursor-paging workloads.

ionos_dbaas_mongodb_top_insert_count

The number of active insert operations on each MongoDB node. Monitor this metric to identify any bulk inserts.

ionos_dbaas_mongodb_top_queries_count

The number of active query operations per MongoDB node. Monitor this metric to identify long-running queries and tune indexes.

ionos_dbaas_mongodb_top_readLock_count

The number of active operations that hold a readLock on each MongoDB node. Monitor this metric to identify read-heavy operations and optimize query patterns.

ionos_dbaas_mongodb_top_remove_count

The number of active remove or delete operations on each MongoDB node. Monitor this metric to identify workloads that need to be deleted.

ionos_dbaas_mongodb_top_total_count

The total number of active operations of all types, such as queries, inserts, updates, deletes, and so on. Monitor this metric to obtain a health snapshot of overall workload intensity.

ionos_dbaas_mongodb_top_update_count

The number of active update operations on each MongoDB node. Monitor this metric to identify any workloads that are particularly update-heavy.

ionos_dbaas_mongodb_top_writeLock_count

The number of operations holding a write-lock on each MongoDB node. Monitor this metric to detect any write-lock contentions and adjust indexes accordingly.

Before you begin

You need to activate the Logging Service to create the necessary setup to view the Grafana dashboard. To do so, Create a Logging Pipeline. This establishes a successful logging pipeline connection. You can view the created logging pipeline in the Logging Service page. For more information, see View Logging Pipelines.

MongoDB Metrics Access using Grafana

1

Open Grafana Dashboard

1. From the Logging Service page, click Grafana Dashboard. The URL to the Grafana sign-in page opens in the browser.

Grafana Dashboard

2. Click Sign in with IONOS from the Grafana sign-in page.

3. Use the IONOS Cloud Data Center Designer (DCD) Single Sign-On (SSO) credentials and click Sign In.

DCD SSO
2

Configure the Data Source

1. From the Grafana home page, on the left-hand menu, go to Connections > Data sources.

2. From the Data sources page, select IONOS Telemetry.

IONOS Telemetry Data Sources

3. In the Settings tab, go to the Authentication section > HTTP headers.

4. Select Add header. You need to add an authorization header with a bearer token. To do so, configure the following:

  • Header: In this field, enter Authorization.

  • Value: Obtain the bearer token value from the Token Manager section in the DCD and prefix Bearer before the Token Value and add it here. For more information, see Generate authentication token.

5. Click Save & test, available at the end of the Settings page.

3

View MongoDB Database Metrics

1. From the Grafana home page, on the left-hand menu, go to Explore > Metrics.

2. Select Let's start! to start metrics exploration and choose IONOS Telemetry as the Data source.

Metrics

3. In the Search metrics, type the keywords such as mongodb to view metrics related to MongoDB.

MongoDB metrics

Summary

MongoDB cluster metrics are accessible through the Grafana dashboard. This functionality is available when a logging pipeline connection is established and the cluster is active within your contract.

Alternatively, you can deploy and configure their own Grafana instance. In this case, establishing a logging pipeline connection is not required. Instead, you can directly configure the appropriate data sources in Grafana to visualize and monitor MongoDB cluster metrics.

Last updated

Was this helpful?