Data configurationGrafana integrationsIntegrations referenceMongoDB integration

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.

It creates 3 different dashboards for monitoring a MongoDB cluster, a specific instance and a ReplicaSet. It also ships the following Prometheus alerts:

  • MongodbDown: A MongoDB instance is down - Critical
  • MongodbReplicationLag: MongoDB replication lag is more than 10s - Critical
  • MongodbReplicationHeadroom: MongoDB replication headroom is <= 0 - Critical
  • MongodbNumberCursorsOpen: Too many cursors opened by MongoDB for clients (> 10k) - Warning
  • MongodbCursorsTimeouts: Too many cursors are timing out - Warning
  • MongodbTooManyConnections: Too many connections (above 80% of the historical average) - warning
  • MongodbVirtualMemoryUsage: MongoDB virtual memory usage more than 3x higher than mapped memory - warning

In order for this integration to work prorperly, you have to 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:

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

We strongly recommend that you configure a separate user for the Agent, and give it only the strictly mandatory security privileges necessary for monitoring your node. For more information, see the official documentation.

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