Menu
Grafana Cloud

Configure a MongoDB exporter to generate Prometheus metrics

Use the recommended Percona MongoDB Exporter to export MongoDB metrics in Prometheus format.

To configure a MongoDB exporter, complete the following steps:

  1. Run the following command to start the Docker version of the exporter:

    docker run -d -p 9216:9216 -p 17001:17001 percona/mongodb_exporter:0.39 --mongodb.uri=mongodb://mongodb:17001
  2. Use MONGODB_USER and MONGODB_PASSWORD to pass credentials.

    Alternatively, you can use the MongoDB exporter Prometheus community helm chart.

Request and error metrics

MetricKey Performance Indicator

|

mongodb_op_counters_total
|

Request Rate

rate(mongodb_op_counters_total[5m])

| |

mongodb_op_counters_repl_total
mongodb_mongod_op_counters_repl_total
|

Request Rate

rate(…[5m])

| |

mongodb_mongod_op_latencies_ops/latencies_total
|

Latency Average

rate(mongodb_mongod_op_latencies_latency_total[5m])
/
rate(mongodb_mongod_op_latencies_ops_total[5m])
|

Resource metrics

MetricKey Performance Indicator
Connection Counts mongodb_ss_connections

Connection Usage

mongodb_ss_connections{conn_type=“current”}

/ ignoring(conn_type) (mongodb_ss_connections{conn_type=“current”} + ignoring(conn_type) mongodb_ss_connections{conn_type=“available”}) |

Alerts

KPIAlert
Request RateRequestRateAnomaly
Latency AverageLatencyAverageAnomaly, LatencyAverageBreach
Connection UsageSaturation with a severity level of critical when utilization exceeds 90%

Failure alerts

AlertDescription
MongodbDownFires when Mongo DB is down
MongodbReplicaMemberUnhealthyFires when a replica in a replication set is unhealthy
MongodbReplicationLagFires when the replication lag of a secondary is more than a configured time duration. Severity is set to warning when lag > 60s and critical when lag > 240s.
MongodbReplicationHeadroomFires when the replication lag of a secondary is more than a configured time duration. Severity is set to warning when lag > 60s and critical when lag > 240s.
MongodbTooManyCursorsOpenFires when the number of open cursors is above a given threshold. By default, the threshold is set to 10000. Severity is set to warning.
MongodbTooManyCursorTimeoutsFires if the rate of cursor timeout is above a certain threshold. By default, the threshold is set to 100. Severity is set to warning.
MongodbInternalErrorsFires when the count of internal errors keeps growing for 5m. Severity is set to warning.
MongodbUserErrorsFires when the count of user errors keeps growing for 5m. Severity is set to warning.
ReadRequestsQueueingUpIf the read queue keeps growing for 5m. Severity is set to warning.
WriteRequestsQueueingUpIf the write queue keeps growing for 5m. Severity is set to warning.

Dashboard

The following image shows an example of the MongoDB Instance Summary Dashboard.

MongoDB Instance Summary Dashboard