Reactive Scala Driver for MongoDB

Asynchronous & Non-Blocking


ReactiveMongo provides a mechanism to collect some metrics about MongoDB connections, that can be useful to monitor.



A JMX module is available.

When running with this module, you can check the state of the ReactiveMongo pools from outside the JVM, using a JMX client.

It can be enabled by adding the dependency as bellow.

"org.reactivemongo" %% "reactivemongo-jmx" % "1.0.2"

Using JConsole:

In order to monitor with jconsole, first start it and select the ReactiveMongo JVM.

JConsole startup

The following warning may be display when connecting to a JVM without SSL (e.g. for local JVMs).

JConsole warning

Once connected, you can select the “MBeans” tab on the top of JConsole, to check the beans managed in the JVM, including those representing the MongoDB nodes managed by ReactiveMongo.

JConsole Node MBean


Kamon is an instrumentation and monitoring library for JVM application.

For projects where Kamon is set up, the module reactivemongo-kamon can to added as bellow, to collect metrics about the connection pools.

"org.reactivemongo" %% "reactivemongo-kamon" % "1.0.2"

Then the metrics can be configured in dashboards, according the used Kamon reporters. For example if using Kamon APM.

Create a graph in Kamon APM

Graph about established connections

The collected metrics are the following.

Spans/Events: (tagged by pool name)

Pool metrics: (tagged by pool name)

Node metrics: (tagged by pool & node)


This library exposes the ReactiveMongo metrics using StatsD integration for Datadog.

"org.reactivemongo" %% "reactivemongo-datadog" % "1.0.2"

Events: (tagged by pool name)

Pool metrics: (tagged by pool name)

Node metrics: (tagged by pool & node)

Datadog node metrics

Application configuration

The application using the driver must configure the Datadog monitoring using a file application.conf (or reference.conf), that must be found in the classpath.

The following settings are mandatory.

If reactivemongo.datadog.hostname is missing, the monitoring is not started.

Minimal configuration sample:

reactivemongo {
  datadog {
    hostname = "localhost"
    port = 8125

The following settings are optional (see documentation).

Datadog metric collection is always set in non-blocking mode.

See complete example


This can be debugged using Netcat, using an alternative port (e.g. 8126), to ensure the monitoring is properly started: nc -u -l 8126 | grep reactivemongo; Must display StatsD entries as bellow.

_e{40,461}:reactivemongo.reactivemongo.pool-created|MongoConnectionOptions { appName: Supervisor-1/Connection-1, authenticationMechanism: SCRAM-SHA-1, nbChannelsPerNode: 10, maxInFlightRequestsPerChannel: 200, minIdleChannelsPerNode: 1, heartbeatFrequencyMS: 10000ms, connectTimeoutMS: 0ms, maxIdleTimeMS: 0ms, tcpNoDelay: false, keepAlive: false, sslEnabled: false, sslAllowsInvalidCert: false, writeConcern: WriteConcern(WaitForAcknowledgments(1),false,false,None), readPreference: Primary, readConcern: local }|d:1605894402|h:myapp|k:Supervisor-1|t:info|s:reactivemongo|#Supervisor-1.Connection-1,Supervisor-1_e{26,113}:reactivemongo.pool-updated||d:1605894403|h:myapp|k:Supervisor-1|t:info|s:reactivemongo|#Supervisor-1.Connection-1,Supervisor-1reactivemongo.awaitingRequests:0|g|#Supervisor-1.Connection-1,Supervisor-1

Agent configuration

The mandatory setting reactivemongo.datadog.hostname must correspond to the accessible network address or hostname of the Datadog agent (e.g. localhost if the application and the agent are on the same machine).

Also the setting reactivemongo.datadog.port must match the way the Datadog agent is configured for StatsD (e.g 8125 in the following example).

First, edit datadog.yml and add the following settings:

use_dogstatsd: true
dogstatsd_port: 8125 # UDP

After the agent is restarted, this can be tested from shell.

while true; do ((echo -n "$RANDOM|c" | nc -4u -w1 ${DATADOGD_UDP_HOST} ${DATADOGD_UDP_PORT}) && sleep 1s); done


Automatic ReactiveMongo Monitoring is part of Instana’s comprehensive microservices and cloud-native application monitoring solution.

See documentation

Suggest changes