Skip to main content

MongoDB monitoring with Netdata

MongoDB MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL).

source: Wikipedia


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.

    # MongoDB 2.x.
    db.addUser("netdata", "<UNIQUE_PASSWORD>", true)

    # MongoDB 3.x or higher.
    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 metris are available on shards only for mongos
MetricScopeDimensionsUnits
operationsglobalinsert, query, update, delete, getmore, commandops/s
operations_latencyglobalreads, writes, commandsmilliseconds
connectionsglobalcurrent, availableconnections
connections_rateglobalcreatedconnections/s
connections_stateglobalactive, threaded, exhaustIsMaster, exhaustHello, awaiting_topology_changesconnections
network_ioglobalin, outbytes/s
network_requestsglobalrequestsrequests/s
page_faultsglobalpage_faultspage_faults/s
tcmalloc_genericglobalcurrent_allocated, heap_sizebytes
tcmallocglobalpageheap_free, pageheap_unmapped, total_threaded_cache, free, pageheap_committed, pageheap_total_commit, pageheap_decommit, pageheap_reservebytes
assertsglobalregular, warning, msg, user, tripwire, rolloversasserts/s
current_transactionsglobalactive, inactive, open, preparedtransactions
shard_commit_typesglobalno_shard_init, no_shard_successful, single_shard_init, single_shard_successful, shard_write_init, shard_write_successful, two_phase_init, two_phase_successfulcommits
active_clientsglobalreaders, writersclients
queued_operationsglobalreaders, writersoperation
locksglobalglobal_read, global_write, database_read, database_write, collection_read, collection_writeoperation
flow_control_timingsglobalacquiring, laggedmilliseconds
wiredtiger_blocksglobalread, read_via_memory_map_api, read_via_system_call_api, written, written_for_checkpoint, written_via_memory_map_apibytes
wiredtiger_cacheglobalallocated_for_updates, read_into_cache, written_from_cachebytes
wiredtiger_capacityglobaldue_to_total_capacity, during_checkpoint, during_eviction, during_logging, during_readusec
wiredtiger_connectionglobalmemory_allocations, memory_frees, memory_re_allocationsops/s
wiredtiger_cursorglobalopen_count, cached_count, bulk_loaded_insert_calls, close_calls_that_result_in_cache, create_calls, insert_calls, modify_calls, next_calls, operation_restarted, prev_calls, remove_calls, reserve_calls, cursor_reset_calls, search_calls, search_history_store_calls, search_near_calls, sweep_buckets, sweep_cursors_closed, sweep_cursors_examined, sweeps, truncate_calls, update_callscalls/s
wiredtiger_lockglobalcheckpoint, dhandle_read, dhandle_write, durable_timestamp_queue_read, durable_timestamp_queue_write, metadata, read_timestamp_queue_read, read_timestamp_queue_write, schema, table_read, table_write, txn_global_readops/s
wiredtiger_lock_durationglobalcheckpoint, checkpoint_internal_thread, dhandle_application_thread, dhandle_internal_thread, durable_timestamp_queue_application_thread, durable_timestamp_queue_internal_thread, metadata_application_thread, metadata_internal_thread, read_timestamp_queue_application_thread, read_timestamp_queue_internal_thread, schema_application_thread, schema_internal_threadoperation
wiredtiger_log_opsglobalflush, force_write, force_write_skipped, scan, sync, sync_dir, writeops/s
wiredtiger_transactionsglobalprepared, query_timestamp, rollback_to_stable, set_timestamp, begins, sync, committed, rolled backtransactions/s
database_collectionsglobala dimension per databasecollections
database_indexesglobala dimension per databaseindexes
database_viewsglobala dimension per databaseviews
database_documentsglobala dimension per databasedocuments
database_storage_sizeglobala dimension per databasebytes
replication_lagglobala dimension per replication membermilliseconds
replication_heartbeat_latencyglobala dimension per replication membermilliseconds
replication_node_pingglobala dimension per replication membermilliseconds
shard_nodes_countglobalshard_aware, shard_unawarenodes
shard_databases_statusglobalpartitioned, un-partitioneddatabases
chunksglobala dimension per shardchunks

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

Sample using connection string:

This is the preferred way

uri: 'mongodb://localhost:27017'

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

Was this page helpful?

Contribute