Skip to main content

MongoDB collector

MongoDB is a source-available cross-platform document-oriented database program.

This module monitors one or more MongoDB instances, depending on your configuration. It collects information and statistics about the server executing the following commands:

Prerequisites

Create a read-only user for Netdata in the admin database.

  • Authenticate as the admin user:

    use admin
    db.auth("admin", "<MONGODB_ADMIN_PASSWORD>")
  • Create a user:

    db.createUser({
    "user":"netdata",
    "pwd": "<UNIQUE_PASSWORD>",
    "roles" : [
    {role: 'read', db: 'admin' },
    {role: 'clusterMonitor', db: 'admin'},
    {role: 'read', db: 'local' }
    ]
    })

Metrics

All metrics have "mongodb." prefix.

  • WireTiger metrics are available only if WiredTiger is used as the storage engine.
  • Sharding metrics are available on shards only for mongos.

Labels per scope:

  • global: no labels.
  • lock type: lock_type.
  • commit type: commit_type.
  • database: database.
  • replica set member: repl_set_member.
  • shard: shard_id.
MetricScopeDimensionsUnits
operations_rateglobalreads, writes, commandsoperations/s
operations_latency_timeglobalreads, writes, commandsmilliseconds
operations_by_type_rateglobalinsert, query, update, delete, getmore, commandoperations/s
document_operations_rateglobalinserted, deleted, returned, updatedoperations/s
scanned_indexes_rateglobalscannedindexes/s
scanned_documents_rateglobalscanneddocuments/s
active_clients_countglobalreads, writesclients
queued_operations_countglobalreads, writesoperations
lock_acquisitions_ratelock typeshared, exclusive, intent_shared, intent_exclusiveacquisitions/s
cursors_open_countglobalopencursors
cursors_open_no_timeout_countglobalopen_no_timeoutcursors
cursors_opened_rateglobalopenedcursors/s
cursors_timed_out_rateglobaltimed_outcursors/s
cursors_by_lifespan_countgloballe_1s, 1s_5s, 5s_15s, 15s_30s, 30s_1m, 1m_10m, ge_10mcursors
transactions_countglobalactive, inactive, open, preparedtransactions
transactions_rateglobalstarted, aborted, committed, preparedtransactions/s
transactions_commits_ratecommit typesuccess, failcommits/s
transactions_commits_duration_timecommit typecommitsmilliseconds
connections_usageglobalavailable, usedconnections
connections_by_state_countglobalactive, threaded, exhaust_is_master, exhaust_hello, awaiting_topology_changesconnections
connections_rateglobalcreatedconnections/s
asserts_rateglobalregular, warning, msg, user, tripwire, rolloversasserts/s
network_traffic_rateglobalin, outbytes/s
network_requests_rateglobalrequestsrequests/s
network_slow_dns_resolutions_rateglobalslow_dnsresolutions/s
network_slow_ssl_handshakes_rateglobalslow_sslhandshakes/s
memory_resident_sizeglobalusedbytes
memory_virtual_sizeglobalusedbytes
memory_page_faults_rateglobalpgfaultspgfaults/s
memory_tcmalloc_statsglobalallocated, central_cache_freelist, transfer_cache_freelist, thread_cache_freelists, pageheap_freelist, pageheap_unmappedbytes
wiredtiger_concurrent_read_transactions_usageglobalavailable, usedtransactions
wiredtiger_concurrent_write_transactions_usageglobalavailable, usedtransactions
wiredtiger_cache_usageglobalusedbytes
wiredtiger_cache_dirty_space_sizeglobaldirtybytes
wiredtiger_cache_io_rateglobalread, writtenpages/s
wiredtiger_cache_evictions_rateglobalunmodified, modifiedpages/s
database_collection_countdatabasecollectionscollections
database_indexes_countdatabaseindexesindexes
database_views_countdatabaseviewsviews
database_documents_countdatabasedocumentsdocuments
database_data_sizedatabasedata_sizebytes
database_storage_sizedatabasestorage_sizebytes
database_index_sizedatabaseindex_sizebytes
repl_set_member_statereplica set memberprimary, startup, secondary, recovering, startup2, unknown, arbiter, down, rollback, removedstate
repl_set_member_health_statusreplica set memberup, downstatus
repl_set_member_replication_lag_timereplica set memberreplication_lagmilliseconds
repl_set_member_heartbeat_latency_timereplica set memberheartbeat_latencymilliseconds
repl_set_member_ping_rtt_timereplica set memberping_rttmilliseconds
repl_set_member_uptimereplica set memberuptimeseconds
sharding_nodes_countglobalshard_aware, shard_unawarenodes
sharding_sharded_databases_countglobalpartitioned, unpartitioneddatabases
sharding_sharded_collections_countglobalpartitioned, unpartitionedcollections
sharding_shard_chunks_countshardchunkschunks

Configuration

Edit the go.d/mongodb.conf configuration file using edit-config from the Netdata config directory, which is typically at /etc/netdata.

cd /etc/netdata   # Replace this path with your Netdata config directory, if different
sudo ./edit-config go.d/mongodb.conf

Needs only connection URI. Here is an example for 2 servers:

jobs:
- name: local
uri: 'mongodb://user:[email protected]:27017'
databases:
include:
- "* *"

- name: remote
dsn: 'mongodb://user:[email protected]:27017'
databases:
include:
- "* *"

If no configuration is given, module will attempt to connect to mongodb daemon on 127.0.0.1:27017 address.

For all available options, see the mongodb collector's configuration file.

Troubleshooting

To troubleshoot issues with the mongodb collector, run the go.d.plugin with the debug option enabled. The output should give you clues as to why the collector isn't working.

  • Navigate to the plugins.d directory, usually at /usr/libexec/netdata/plugins.d/. If that's not the case on your system, open netdata.conf and look for the plugins setting under [directories].

    cd /usr/libexec/netdata/plugins.d/
  • Switch to the netdata user.

    sudo -u netdata -s
  • Run the go.d.plugin to debug the collector:

    ./go.d.plugin -d -m mongodb

Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.