Grafana Cloud

MongoDB integration for Grafana Cloud

MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.

This integration includes 10 useful alerts and 3 pre-built dashboards to help monitor and visualize MongoDB metrics.

Before you begin

We strongly recommend that you configure a separate user for Grafana Alloy and give it only the strictly mandatory security privileges necessary for monitoring your node.

Install MongoDB integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find MongoDB and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send MongoDB metrics to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your MongoDB setup.

Configuration snippets for Grafana Alloy

Advanced mode

To instruct Grafana Alloy to scrape your MongoDB nodes, go though the subsequent instructions.

The snippets provide examples to guide you through the configuration process.

First, manually copy and append the following snippets into your Grafana Alloy configuration file.

Then follow the instructions below to modify the necessary variables.

Advanced integrations snippets

prometheus.exporter.mongodb "integrations_mongodb_exporter" {
    mongodb_uri    = "mongodb://username:password:<hostname>:27017"
    direct_connect = true
discovery.relabel "integrations_mongodb_exporter" {
    targets = prometheus.exporter.mongodb.integrations_mongodb_exporter.targets

    rule {
        target_label = "service_name"
        replacement  = "<your-service-name>"

    rule {
        target_label = "mongodb_cluster"
        replacement  = "<your-cluster-name>"

    rule {
        target_label = "instance"
        replacement  = "<your-instance-name>"
prometheus.scrape "integrations_mongodb_exporter" {
    targets    = discovery.relabel.integrations_mongodb_exporter.output
    forward_to = [prometheus.remote_write.metrics_service.receiver]
    job_name   = "integrations/mongodb_exporter"

Add a pair of prometheus.exporter.mongodb and discovery.relabel to your Grafana Alloy configuration file for each MongoDB node you monitor, to avoid instance label conflicts.

Configure the following property within the prometheus.exporter.mongodb component:

  • mongodb_uri: The URI to connect to your MongoDB node.

Refer to prometheus.exporter.mongod in Grafana Alloy reference documentation for a complete description of the configuration options.

Configure the following properties within the discovery.relabel component:

  • <your-instance-name>: The instance label for all metrics from this MongoDB node.
  • <your-cluster-name>: The mongodb_cluster label to group your Kafka nodes within a cluster. Set the same value for all nodes within your cluster.
  • <your-service-name>: The label used to group your nodes by type, for example, “Mongos”, “ConfigServer”, “Shard”. This will be used to filter by node type on your dashboards.

Finally, reference each discovery.relabel component within the targets property of the prometheus.scrape component.

Grafana Agent static configuration (deprecated)

The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.


The MongoDB integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • MongoDB Cluster
  • MongoDB Instance
  • MongoDB ReplicaSet

Cluster Overview

Cluster Overview

Instance Overview

Instance Overview

ReplicaSet Overview

ReplicaSet Overview


The MongoDB integration includes the following useful alerts:

MongodbCursorsTimeoutsWarning: MongoDB cursors timeouts is exceeding the threshold.
MongodbDownCritical: MongoDB Instance is Down.
MongodbNumberCursorsOpenWarning: MongoDB number cursors open too high.
MongodbReadRequestsQueueingUpWarning: MongoDB read requests queuing up.
MongodbReplicaMemberUnhealthyCritical: MongoDB replica member unhealthy.
MongodbReplicationHeadroomCritical: MongoDB replication headroom is exceeding the threshold.
MongodbReplicationLagCritical: MongoDB replication lag is exceeding the threshold.
MongodbTooManyConnectionsWarning: MongoDB too many connections.
MongodbVirtualMemoryUsageWarning: MongoDB virtual memory usage is too high.
MongodbWriteRequestsQueueingUpWarning: MongoDB write requests queuing up.


The most important metrics provided by the MongoDB integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

  • mongodb_asserts_total
  • mongodb_connections
  • mongodb_extra_info_page_faults_total
  • mongodb_instance_uptime_seconds
  • mongodb_memory
  • mongodb_mongod_asserts_total
  • mongodb_mongod_connections
  • mongodb_mongod_cursors
  • mongodb_mongod_extra_info_page_faults_total
  • mongodb_mongod_global_lock_current_queue
  • mongodb_mongod_metrics_cursor_open
  • mongodb_mongod_metrics_cursor_timed_out_total
  • mongodb_mongod_metrics_document_total
  • mongodb_mongod_metrics_get_last_error_wtime_num_total
  • mongodb_mongod_metrics_get_last_error_wtime_total_milliseconds
  • mongodb_mongod_metrics_get_last_error_wtimeouts_total
  • mongodb_mongod_metrics_query_executor_total
  • mongodb_mongod_metrics_record_moves_total
  • mongodb_mongod_metrics_repl_apply_batches_total_milliseconds
  • mongodb_mongod_metrics_repl_apply_ops_total
  • mongodb_mongod_metrics_repl_buffer_count
  • mongodb_mongod_metrics_repl_network_getmores_total_milliseconds
  • mongodb_mongod_metrics_repl_preload_docs_num_total
  • mongodb_mongod_metrics_repl_preload_docs_total_milliseconds
  • mongodb_mongod_metrics_repl_preload_indexes_num_total
  • mongodb_mongod_metrics_repl_preload_indexes_total_milliseconds
  • mongodb_mongod_metrics_ttl_deleted_documents_total
  • mongodb_mongod_op_counters_repl_total
  • mongodb_mongod_op_counters_total
  • mongodb_mongod_op_latencies_latency_total
  • mongodb_mongod_op_latencies_ops_total
  • mongodb_mongod_replset_member_election_date
  • mongodb_mongod_replset_member_health
  • mongodb_mongod_replset_member_last_heartbeat
  • mongodb_mongod_replset_member_optime_date
  • mongodb_mongod_replset_member_ping_ms
  • mongodb_mongod_replset_member_replication_lag
  • mongodb_mongod_replset_my_name
  • mongodb_mongod_replset_my_state
  • mongodb_mongod_replset_number_of_members
  • mongodb_mongod_replset_oplog_head_timestamp
  • mongodb_mongod_replset_oplog_tail_timestamp
  • mongodb_mongos_asserts_total
  • mongodb_mongos_connections
  • mongodb_mongos_cursors
  • mongodb_mongos_db_collections_total
  • mongodb_mongos_db_data_size_bytes
  • mongodb_mongos_db_index_size_bytes
  • mongodb_mongos_db_indexes_total
  • mongodb_mongos_extra_info_page_faults_total
  • mongodb_mongos_metrics_cursor_open
  • mongodb_mongos_metrics_get_last_error_wtime_num_total
  • mongodb_mongos_metrics_get_last_error_wtime_total_milliseconds
  • mongodb_mongos_metrics_get_last_error_wtimeouts_total
  • mongodb_mongos_metrics_ttl_deleted_documents_total
  • mongodb_mongos_op_counters_repl_total
  • mongodb_mongos_op_counters_total
  • mongodb_mongos_sharding_balancer_enabled
  • mongodb_mongos_sharding_changelog_10min_total
  • mongodb_mongos_sharding_chunks_is_balanced
  • mongodb_mongos_sharding_chunks_total
  • mongodb_mongos_sharding_collections_total
  • mongodb_mongos_sharding_databases_total
  • mongodb_mongos_sharding_shard_chunks_total
  • mongodb_mongos_sharding_shards_draining_total
  • mongodb_mongos_sharding_shards_total
  • mongodb_op_counters_repl_total
  • mongodb_op_counters_total
  • mongodb_rs_members_pingMs
  • mongodb_up
  • mongodb_version_info
  • up


# 1.1.0 - June 2024

* Add asserts support
* Update mixin

# 1.0.0 - June 2024

* Update mixin to latest version:
  - Fix typos in panel titles

# 0.0.6 - July 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.5 - October 2022

* Update mixin to latest version:
  - Fix missing job label on all the dashboards
  - Adding screenshots

# 0.0.4 - October 2022

* Update mixin to latest version:
  - Fix missing cluster label on ReplicaSet and Instance dashboards

# 0.0.3 - September 2022

* Update mixin to latest version:
  - Fix queryType and datasources

# 0.0.2 - June 2022

* Fixing missing datasource variable on Instance dashboard

# 0.0.1 - October 2021

* Initial release


By connecting your MongoDB instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.