Project: Netdata (Observability and Analysis / Observability)
File: mongodb.md

<!--startmeta customediturl: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/mongodb/README.md" meta_yaml: "https://github.com/netdata/netdata/edit/master/src/go/collectors/go.d.plugin/modules/mongodb/metadata.yaml" sidebar_label: "MongoDB" learn_status: "Published" learnrelpath: "Collecting Metrics/Databases" most_popular: False message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE" endmeta--> <img src="https://netdata.cloud/img/mongodb.svg" width="150"/> Plugin: go.d.plugin Module: mongodb <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" /> This collector monitors MongoDB servers. Executed queries: This collector is supported on all platforms. This collector supports collecting metrics from multiple instances of this integration, including remote instances. This integration doesn't support auto-detection. The default configuration for this integration does not impose any limits on data collection. The default configuration for this integration is not expected to impose a significant performance impact on the system. Metrics grouped by scope. The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels. WireTiger metrics are available only if is used as the storage engine. Sharding metrics are available on shards only for . These metrics refer to the entire monitored application. This scope has no labels. Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.operations_rate | reads, writes, commands | operations/s | | mongodb.operationslatencytime | reads, writes, commands | milliseconds | | mongodb.operationsbytype_rate | insert, query, update, delete, getmore, command | operations/s | | mongodb.documentoperationsrate | inserted, deleted, returned, updated | operations/s | | mongodb.scannedindexesrate | scanned | indexes/s | | mongodb.scanneddocumentsrate | scanned | documents/s | | mongodb.activeclientscount | readers, writers | clients | | mongodb.queuedoperationscount | reads, writes | operations | | mongodb.cursorsopencount | open | cursors | | mongodb.cursorsopennotimeoutcount | opennotimeout | cursors | | mongodb.cursorsopenedrate | opened | cursors/s | | mongodb.cursorstimedoutrate | timedout | cursors/s | | mongodb.cursorsbylifespancount | le1s, 1s5s, 5s15s, 15s30s, 30s1m, 1m10m, ge10m | cursors | | mongodb.transactions_count | active, inactive, open, prepared | transactions | | mongodb.transactions_rate | started, aborted, committed, prepared | transactions/s | | mongodb.connections_usage | available, used | connections | | mongodb.connectionsbystatecount | active, threaded, exhaustismaster, exhausthello, awaitingtopologychanges | connections | | mongodb.connections_rate | created | connections/s | | mongodb.asserts_rate | regular, warning, msg, user, tripwire, rollovers | asserts/s | | mongodb.networktrafficrate | in, out | bytes/s | | mongodb.networkrequestsrate | requests | requests/s | | mongodb.networkslowdnsresolutionsrate | slow_dns | resolutions/s | | mongodb.networkslowsslhandshakesrate | slow_ssl | handshakes/s | | mongodb.memoryresidentsize | used | bytes | | mongodb.memoryvirtualsize | used | bytes | | mongodb.memorypagefaults_rate | pgfaults | pgfaults/s | | mongodb.memorytcmallocstats | allocated, centralcachefreelist, transfercachefreelist, threadcachefreelists, pageheapfreelist, pageheapunmapped | bytes | | mongodb.wiredtigerconcurrentreadtransactionsusage | available, used | transactions | | mongodb.wiredtigerconcurrentwritetransactionsusage | available, used | transactions | | mongodb.wiredtigercacheusage | used | bytes | | mongodb.wiredtigercachedirtyspacesize | dirty | bytes | | mongodb.wiredtigercacheio_rate | read, written | pages/s | | mongodb.wiredtigercacheevictions_rate | unmodified, modified | pages/s | | mongodb.shardingnodescount | shardaware, shardunaware | nodes | | mongodb.shardingshardeddatabases_count | partitioned, unpartitioned | databases | | mongodb.shardingshardedcollections_count | partitioned, unpartitioned | collections | These metrics refer to the lock type. Labels: | Label | Description | |:--|:-| | lock_type | lock type (e.g. global, database, collection, mutex) | Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.lockacquisitionsrate | shared, exclusive, intentshared, intentexclusive | acquisitions/s | These metrics refer to the commit type. Labels: | Label | Description | |:--|:-| | commit_type | commit type

noShards, singleShard, singleWriteShard) | Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.transactionscommitsrate | success, fail | commits/s | | mongodb.transactionscommitsduration_time | commits | milliseconds | These metrics refer to the database. Labels: | Label | Description | |:--|:-| | database | database name | Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.databasecollectioncount | collections | collections | | mongodb.databaseindexescount | indexes | indexes | | mongodb.databaseviewscount | views | views | | mongodb.databasedocumentscount | documents | documents | | mongodb.databasedatasize | data_size | bytes | | mongodb.databasestoragesize | storage_size | bytes | | mongodb.databaseindexsize | index_size | bytes | These metrics refer to the replica set member. Labels: | Label | Description | |:--|:-| | replsetmember | replica set member name | Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.replsetmember_state | primary, startup, secondary, recovering, startup2, unknown, arbiter, down, rollback, removed | state | | mongodb.replsetmemberhealthstatus | up, down | status | | mongodb.replsetmemberreplicationlagtime | replicationlag | milliseconds | | mongodb.replsetmemberheartbeatlatencytime | heartbeatlatency | milliseconds | | mongodb.replsetmemberpingrtttime | pingrtt | milliseconds | | mongodb.replsetmember_uptime | uptime | seconds | These metrics refer to the shard. Labels: | Label | Description | |:--|:-| | shard_id | shard id | Metrics: | Metric | Dimensions | Unit | |:|:-|:-| | mongodb.shardingshardchunks_count | chunks | chunks | There are no alerts configured by default for this integration. Create a read-only user for Netdata in the admin database. Authenticate as the admin user: ```bash use admin db.auth("admin", "<MONGODBADMINPASSWORD>") ``` Create a user: ```bash db.createUser({ "user":"netdata", "pwd": "<UNIQUE_PASSWORD>", "roles" : [ {role: 'read', db: 'admin' }, {role: 'clusterMonitor', db: 'admin'}, {role: 'read', db: 'local' } ] }) ``` The configuration file name for this integration is `go.d/mongodb.conf`. You can edit the configuration file using the `edit-config` script from the Netdata . ```bash cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata sudo ./edit-config go.d/mongodb.conf ``` The following options can be defined globally: updateevery, autodetectionretry. <details><summary>Config options</summary> | Name | Description | Default | Required | |:-|:--|:-|:--:| | update_every | Data collection frequency. | 5 | no | | autodetection_retry | Recheck interval in seconds. Zero means no recheck will be scheduled. | 0 | no | | uri | MongoDB connection string. See . | mongodb://localhost:27017 | yes | | timeout | Query timeout in seconds. | 1 | no | | databases | Databases selector. Determines which database metrics will be collected. | | no | </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local uri: mongodb://netdata:password@localhost:27017 ``` </details> An example configuration. <details><summary>Config</summary> ```yaml jobs: name: local uri: mongodb://netdata:password@localhost:27017 databases: includes: " " ``` </details> Note: When you define multiple jobs, their names must be unique. Local and remote instances. <details><summary>Config</summary> ```yaml jobs: name: local uri: mongodb://netdata:password@localhost:27017 name: remote uri: mongodb://netdata:password@203.0.113.0:27017 ``` </details> 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]`. ```bash cd /usr/libexec/netdata/plugins.d/ ``` Switch to the `netdata` user. ```bash sudo -u netdata -s ``` Run the `go.d.plugin` to debug the collector: ```bash ./go.d.plugin -d -m mongodb ```