---
title: "MongoDB integration | Grafana Cloud documentation"
description: "Learn about MongoDB Grafana Cloud integration."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# 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](https://github.com/percona/mongodb_exporter#permissions) 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 Alloy 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

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
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](/docs/alloy/latest/reference/components/prometheus.exporter.mongodb) and [discovery.relabel](/docs/alloy/latest/reference/components/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](/docs/alloy/latest/reference/components/prometheus.exporter.mongodb/) 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 MongoDB 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](/docs/alloy/latest/reference/components/prometheus.scrape) component.

## Dashboards

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**

**Instance Overview**

**ReplicaSet Overview**

## Alerts

The MongoDB integration includes the following useful alerts:

Expand table

| Alert                          | Description                                                        |
|--------------------------------|--------------------------------------------------------------------|
| MongodbCursorsTimeouts         | Warning: MongoDB cursors timeouts is exceeding the threshold.      |
| MongodbDown                    | Critical: MongoDB Instance is Down.                                |
| MongodbNumberCursorsOpen       | Warning: MongoDB number cursors open too high.                     |
| MongodbReadRequestsQueueingUp  | Warning: MongoDB read requests queuing up.                         |
| MongodbReplicaMemberUnhealthy  | Critical: MongoDB replica member unhealthy.                        |
| MongodbReplicationHeadroom     | Critical: MongoDB replication headroom is exceeding the threshold. |
| MongodbReplicationLag          | Critical: MongoDB replication lag is exceeding the threshold.      |
| MongodbTooManyConnections      | Warning: MongoDB too many connections.                             |
| MongodbVirtualMemoryUsage      | Warning: MongoDB virtual memory usage is too high.                 |
| MongodbWriteRequestsQueueingUp | Warning: MongoDB write requests queuing up.                        |

## Metrics

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

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 1.1.2 - November 2024

- Update status panel check queries

# 1.1.1 - July 2024

* Adds asserts specific variables to dashboards

# 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
```

## 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](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
