Need help with mongodb_exporter?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

710 Stars 335 Forks Apache License 2.0 151 Commits 26 Opened issues


A Prometheus exporter for MongoDB including sharding, replication and storage engines

Services available


Need anything else?

Contributors list

MongoDB exporter

Release Build Status Code Coverage Go Report Card CLA assistant Discord

This is the new MongoDB exporter implementation that handles ALL metrics exposed by MongoDB monitoring commands. This new implementation loops over all the fields exposed in diagnostic commands and tries to get data from them.

Currently, these metric sources are implemented: - $collStats - $indexStats - getDiagnosticData - replSetGetStatus - serverStatus

Info on Percona MongoDB exporter versions

The old 0.1x.y version (ex

branch) has been moved to the

A flag,

, which exposes metrics with 0.1x compatible metric names has been implemented which simplifies migration from the old version to the current version.


|Flag|Description|Example| |-----|-----|-----| |-h, --help|Show context-sensitive help|| |--compatible-mode|Exposes new metrics in the new and old format at the same time|| |--discovering-mode|Enable autodiscover collections from databases which set in collstats-colls and indexstats-colls|| |--mongodb.collstats-colls|List of comma separated databases.collections to get stats|--mongodb.collstats-colls=testdb.testcol1,testdb.testcol2| ||Whether or not a direct connect should be made. Direct connections are not valid if multiple hosts are specified or an SRV URI is used|| |--mongodb.indexstats-colls|List of comma separated database.collections to get index stats|--mongodb.indexstats-colls=db1.col1,db1.col2| |--mongodb.uri|MongoDB connection URI ($MONGODB_URI)|--mongodb.uri=mongodb://user:[email protected]:27017/admin?ssl=true| ||Use global connection pool instead of creating new connection for each http request.|| |--web.listen-address|Address to listen on for web interface and telemetry|--web.listen-address=":9216"| |--web.telemetry-path|Metrics expose path|--web.telemetry-path="/metrics"| |--log.level|Only log messages with the given severity or above. Valid levels: [debug, info, warn, error]|--log.level=error| |--no-collector.diagnosticdata|Disable collecting metrics from getDiagnosticData|| |--no-collector.replicasetstatus|Disable collecting metrics from replSetGetStatus|| |--collector.dbstats|Enable collecting metrics from dbStats|| ||Enable collecting metrics from top admin command|| |--version|Show version and exit|

Build the exporter

The build process uses the dockerized version of goreleaser so you don't need to install Go. Just run

make release
and the new binaries will be generated under the build directory.
├── build
│ ├── config.yaml
│ ├── mongodb_exporter_7c73946_checksums.txt
│ ├── mongodb_exporter-7c73946.darwin-amd64.tar.gz
│ ├── mongodb_exporter-7c73946.linux-amd64.tar.gz
│ ├── mongodb_exporter_darwin_amd64
│ │ └── mongodb_exporter 

Running the exporter

If you built the exporter using the method mentioned in the previous section, the generated binaries are in



A docker image is available on the official percona repository.

# with podman
podman run -d -p 9216:9216 -p 17001:17001 percona/mongodb_exporter:0.20 --mongodb.uri=mongodb://

with docker

docker run -d -p 9216:9216 -p 17001:17001 percona/mongodb_exporter:0.20 --mongodb.uri=mongodb://


Connecting user should have sufficient rights to query needed stats:


More info about roles in MongoDB documentation.


mongodb_exporter_linux_amd64/mongodb_exporter --mongodb.uri=mongodb://

Enabling collstats metrics gathering

receives a list of databases and collections to monitor using collstats. Usage example:
mongodb_exporter_linux_amd64/mongodb_exporter --mongodb.uri=mongodb:// --mongodb.collstats-colls=db1.c1,db2.c2

Enabling compatibility mode.

When compatibility mode is enabled by the

, the exporter will expose all new metrics with the new naming and labeling schema and at the same time will expose metrics in the version 1 compatible way. For example, if compatibility mode is enabled, the metric
(new format) ```

HELP mongodbsswtloglogbyteswritten serverStatus.wiredTiger.log.

TYPE mongodbsswtloglogbyteswritten untyped

mongodbsswtloglogbyteswritten 2.6208e+06

will be also exposed as `mongodb_mongod_wiredtiger_log_bytes_total`  with the `unwritten` label.
HELP mongodbmongodwiredtigerlogbytestotal mongodbmongodwiredtigerlogbytestotal

TYPE mongodbmongodwiredtigerlogbytes_total untyped

mongodbmongodwiredtigerlogbytes_total{type="unwritten"} 2.6208e+06 ```

Cluster role labels

The exporter sets some topology labels in all metrics. The labels are:

  • cl_role: Cluster role according to this table:

|Server type|Label| |-----|-----| |mongos|mongos| |regular instance (primary or secondary)|shardsvr| |arbiter|shardsvr| |standalone|(empty string)|

  • cl_id: Cluster ID
  • rs_nm: Replicaset name
  • rs_state: Replicaset state is an integer from
    . Check the official documentation for details on replicaset status values.

Submitting Bug Reports and adding new functionality

please see Contribution Guide

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.