Menu

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 monitors a MongoDB Cluster using the Percona MongoDB Exporter, which is embedded in the Grafana Agent for ease of use, from version 0.19.0 upwards.

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

Install MongoDB integration for Grafana Cloud

  1. In your Grafana Cloud instance, click Integrations and Connections (lightning bolt icon).
  2. Navigate to the MongoDB tile and review the prerequisites. Then click Install integration.
  3. Once the integration is installed, follow the steps on the Configuration Details page to setup Grafana Agent and start sending MongoDB metrics to your Grafana Cloud instance.

Post-install configuration for the MongoDB integration

This integration monitors a MongoDB Cluster using the Percona MongoDB Exporter, which is embedded in the Grafana Agent for ease of use, from version 0.19.0 upwards.

In order for this integration to work, you must connect each node of your mongoDB cluster to an agent instance. That’s because this exporter does not collect metrics from multiple nodes.

Additionally, you need to define two custom label for you metrics using relabel_configs.

The first one is service_name, which is how you identify this node in your cluster (example: ReplicaSet1-Node1). The second one is mongodb_cluster, which is the name of your mongodb cluster, and must be set the same value for all nodes composing the cluster (example: prod-cluster).

Here`s an example:

relabel_configs:
    - source_labels: [__address__]
      target_label: service_name
      replacement: 'replicaset1-node1'
    - source_labels: [__address__]
      target_label: mongodb_cluster
      replacement: 'prod-cluster'

It’s recommend that you configure a separate user for the Agent, and give it only the strictly mandatory security privileges necessary for monitoring your node, as per the official documentation.

Please refer to the full reference of options on the Grafana Agent configuration reference.

Dashboards

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

  • MongoDB Cluster
  • MongoDB Instance
  • MongoDB ReplicaSet

Cluster Overview

image

Instance Overview

image

ReplicaSet Overview

image

Alerts

The MongoDB integration includes the following useful alerts:

Group: MongodbAlerts

AlertDescription
MongodbDownCritical: MongoDB Instance is Down.
MongodbReplicationLagCritical: MongoDB replication lag is exceeding the threshold.
MongodbReplicationHeadroomCritical: MongoDB replication headroom is exceeding the threshold.
MongodbNumberCursorsOpenWarning: MongoDB number cursors open too high.
MongodbCursorsTimeoutsWarning: MongoDB cursors timeouts is exceeding the threshold.
MongodbTooManyConnectionsWarning: MongoDB too many connections.
MongodbVirtualMemoryUsageWarning: MongoDB virtual memory usage is too high.

Metrics

The following metrics are automatically written to your Grafana Cloud instance by connecting your MongoDB instance through this integration:

  • 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_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

Changelog

# 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

Cost

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.