github.com/netdata/go.d.plugin@v0.58.1/modules/mongodb/integrations/mongodb.md (about)

     1  <!--startmeta
     2  custom_edit_url: "https://github.com/netdata/go.d.plugin/edit/master/modules/mongodb/README.md"
     3  meta_yaml: "https://github.com/netdata/go.d.plugin/edit/master/modules/mongodb/metadata.yaml"
     4  sidebar_label: "MongoDB"
     5  learn_status: "Published"
     6  learn_rel_path: "Data Collection/Databases"
     7  most_popular: False
     8  message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
     9  endmeta-->
    10  
    11  # MongoDB
    12  
    13  
    14  <img src="https://netdata.cloud/img/mongodb.svg" width="150"/>
    15  
    16  
    17  Plugin: go.d.plugin
    18  Module: mongodb
    19  
    20  <img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
    21  
    22  ## Overview
    23  
    24  This collector monitors MongoDB servers.
    25  
    26  Executed queries:
    27  
    28  - [serverStatus](https://docs.mongodb.com/manual/reference/command/serverStatus/)
    29  - [dbStats](https://docs.mongodb.com/manual/reference/command/dbStats/)
    30  - [replSetGetStatus](https://www.mongodb.com/docs/manual/reference/command/replSetGetStatus/)
    31  
    32  
    33  
    34  
    35  This collector is supported on all platforms.
    36  
    37  This collector supports collecting metrics from multiple instances of this integration, including remote instances.
    38  
    39  
    40  ### Default Behavior
    41  
    42  #### Auto-Detection
    43  
    44  This integration doesn't support auto-detection.
    45  
    46  #### Limits
    47  
    48  The default configuration for this integration does not impose any limits on data collection.
    49  
    50  #### Performance Impact
    51  
    52  The default configuration for this integration is not expected to impose a significant performance impact on the system.
    53  
    54  
    55  ## Metrics
    56  
    57  Metrics grouped by *scope*.
    58  
    59  The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
    60  
    61  - WireTiger metrics are available only if [WiredTiger](https://docs.mongodb.com/v6.0/core/wiredtiger/) is used as the
    62    storage engine.
    63  - Sharding metrics are available on shards only
    64    for [mongos](https://www.mongodb.com/docs/manual/reference/program/mongos/).
    65  
    66  
    67  ### Per MongoDB instance
    68  
    69  These metrics refer to the entire monitored application.
    70  
    71  This scope has no labels.
    72  
    73  Metrics:
    74  
    75  | Metric | Dimensions | Unit |
    76  |:------|:----------|:----|
    77  | mongodb.operations_rate | reads, writes, commands | operations/s |
    78  | mongodb.operations_latency_time | reads, writes, commands | milliseconds |
    79  | mongodb.operations_by_type_rate | insert, query, update, delete, getmore, command | operations/s |
    80  | mongodb.document_operations_rate | inserted, deleted, returned, updated | operations/s |
    81  | mongodb.scanned_indexes_rate | scanned | indexes/s |
    82  | mongodb.scanned_documents_rate | scanned | documents/s |
    83  | mongodb.active_clients_count | readers, writers | clients |
    84  | mongodb.queued_operations_count | reads, writes | operations |
    85  | mongodb.cursors_open_count | open | cursors |
    86  | mongodb.cursors_open_no_timeout_count | open_no_timeout | cursors |
    87  | mongodb.cursors_opened_rate | opened | cursors/s |
    88  | mongodb.cursors_timed_out_rate | timed_out | cursors/s |
    89  | mongodb.cursors_by_lifespan_count | le_1s, 1s_5s, 5s_15s, 15s_30s, 30s_1m, 1m_10m, ge_10m | cursors |
    90  | mongodb.transactions_count | active, inactive, open, prepared | transactions |
    91  | mongodb.transactions_rate | started, aborted, committed, prepared | transactions/s |
    92  | mongodb.connections_usage | available, used | connections |
    93  | mongodb.connections_by_state_count | active, threaded, exhaust_is_master, exhaust_hello, awaiting_topology_changes | connections |
    94  | mongodb.connections_rate | created | connections/s |
    95  | mongodb.asserts_rate | regular, warning, msg, user, tripwire, rollovers | asserts/s |
    96  | mongodb.network_traffic_rate | in, out | bytes/s |
    97  | mongodb.network_requests_rate | requests | requests/s |
    98  | mongodb.network_slow_dns_resolutions_rate | slow_dns | resolutions/s |
    99  | mongodb.network_slow_ssl_handshakes_rate | slow_ssl | handshakes/s |
   100  | mongodb.memory_resident_size | used | bytes |
   101  | mongodb.memory_virtual_size | used | bytes |
   102  | mongodb.memory_page_faults_rate | pgfaults | pgfaults/s |
   103  | mongodb.memory_tcmalloc_stats | allocated, central_cache_freelist, transfer_cache_freelist, thread_cache_freelists, pageheap_freelist, pageheap_unmapped | bytes |
   104  | mongodb.wiredtiger_concurrent_read_transactions_usage | available, used | transactions |
   105  | mongodb.wiredtiger_concurrent_write_transactions_usage | available, used | transactions |
   106  | mongodb.wiredtiger_cache_usage | used | bytes |
   107  | mongodb.wiredtiger_cache_dirty_space_size | dirty | bytes |
   108  | mongodb.wiredtiger_cache_io_rate | read, written | pages/s |
   109  | mongodb.wiredtiger_cache_evictions_rate | unmodified, modified | pages/s |
   110  | mongodb.sharding_nodes_count | shard_aware, shard_unaware | nodes |
   111  | mongodb.sharding_sharded_databases_count | partitioned, unpartitioned | databases |
   112  | mongodb.sharding_sharded_collections_count | partitioned, unpartitioned | collections |
   113  
   114  ### Per lock type
   115  
   116  These metrics refer to the lock type.
   117  
   118  Labels:
   119  
   120  | Label      | Description     |
   121  |:-----------|:----------------|
   122  | lock_type | lock type (e.g. global, database, collection, mutex) |
   123  
   124  Metrics:
   125  
   126  | Metric | Dimensions | Unit |
   127  |:------|:----------|:----|
   128  | mongodb.lock_acquisitions_rate | shared, exclusive, intent_shared, intent_exclusive | acquisitions/s |
   129  
   130  ### Per commit type
   131  
   132  These metrics refer to the commit type.
   133  
   134  Labels:
   135  
   136  | Label      | Description     |
   137  |:-----------|:----------------|
   138  | commit_type | commit type (e.g. noShards, singleShard, singleWriteShard) |
   139  
   140  Metrics:
   141  
   142  | Metric | Dimensions | Unit |
   143  |:------|:----------|:----|
   144  | mongodb.transactions_commits_rate | success, fail | commits/s |
   145  | mongodb.transactions_commits_duration_time | commits | milliseconds |
   146  
   147  ### Per database
   148  
   149  These metrics refer to the database.
   150  
   151  Labels:
   152  
   153  | Label      | Description     |
   154  |:-----------|:----------------|
   155  | database | database name |
   156  
   157  Metrics:
   158  
   159  | Metric | Dimensions | Unit |
   160  |:------|:----------|:----|
   161  | mongodb.database_collection_count | collections | collections |
   162  | mongodb.database_indexes_count | indexes | indexes |
   163  | mongodb.database_views_count | views | views |
   164  | mongodb.database_documents_count | documents | documents |
   165  | mongodb.database_data_size | data_size | bytes |
   166  | mongodb.database_storage_size | storage_size | bytes |
   167  | mongodb.database_index_size | index_size | bytes |
   168  
   169  ### Per replica set member
   170  
   171  These metrics refer to the replica set member.
   172  
   173  Labels:
   174  
   175  | Label      | Description     |
   176  |:-----------|:----------------|
   177  | repl_set_member | replica set member name |
   178  
   179  Metrics:
   180  
   181  | Metric | Dimensions | Unit |
   182  |:------|:----------|:----|
   183  | mongodb.repl_set_member_state | primary, startup, secondary, recovering, startup2, unknown, arbiter, down, rollback, removed | state |
   184  | mongodb.repl_set_member_health_status | up, down | status |
   185  | mongodb.repl_set_member_replication_lag_time | replication_lag | milliseconds |
   186  | mongodb.repl_set_member_heartbeat_latency_time | heartbeat_latency | milliseconds |
   187  | mongodb.repl_set_member_ping_rtt_time | ping_rtt | milliseconds |
   188  | mongodb.repl_set_member_uptime | uptime | seconds |
   189  
   190  ### Per shard
   191  
   192  These metrics refer to the shard.
   193  
   194  Labels:
   195  
   196  | Label      | Description     |
   197  |:-----------|:----------------|
   198  | shard_id | shard id |
   199  
   200  Metrics:
   201  
   202  | Metric | Dimensions | Unit |
   203  |:------|:----------|:----|
   204  | mongodb.sharding_shard_chunks_count | chunks | chunks |
   205  
   206  
   207  
   208  ## Alerts
   209  
   210  There are no alerts configured by default for this integration.
   211  
   212  
   213  ## Setup
   214  
   215  ### Prerequisites
   216  
   217  #### Create a read-only user
   218  
   219  Create a read-only user for Netdata in the admin database.
   220  
   221  - Authenticate as the admin user:
   222  
   223    ```bash
   224    use admin
   225    db.auth("admin", "<MONGODB_ADMIN_PASSWORD>")
   226    ```
   227  
   228  - Create a user:
   229  
   230    ```bash
   231    db.createUser({
   232      "user":"netdata",
   233      "pwd": "<UNIQUE_PASSWORD>",
   234      "roles" : [
   235        {role: 'read', db: 'admin' },
   236        {role: 'clusterMonitor', db: 'admin'},
   237        {role: 'read', db: 'local' }
   238      ]
   239    })
   240    ```
   241  
   242  
   243  
   244  ### Configuration
   245  
   246  #### File
   247  
   248  The configuration file name for this integration is `go.d/mongodb.conf`.
   249  
   250  
   251  You can edit the configuration file using the `edit-config` script from the
   252  Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/configure/nodes.md#the-netdata-config-directory).
   253  
   254  ```bash
   255  cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
   256  sudo ./edit-config go.d/mongodb.conf
   257  ```
   258  #### Options
   259  
   260  The following options can be defined globally: update_every, autodetection_retry.
   261  
   262  
   263  <details><summary>Config options</summary>
   264  
   265  | Name | Description | Default | Required |
   266  |:----|:-----------|:-------|:--------:|
   267  | update_every | Data collection frequency. | 5 | no |
   268  | autodetection_retry | Recheck interval in seconds. Zero means no recheck will be scheduled. | 0 | no |
   269  | uri | MongoDB connection string. See [URI syntax](https://www.mongodb.com/docs/manual/reference/connection-string/). | mongodb://localhost:27017 | yes |
   270  | timeout | Query timeout in seconds. | 2 | no |
   271  | databases | Databases selector. Determines which database metrics will be collected. |  | no |
   272  
   273  </details>
   274  
   275  #### Examples
   276  
   277  ##### TCP socket
   278  
   279  An example configuration.
   280  
   281  <details><summary>Config</summary>
   282  
   283  ```yaml
   284  jobs:
   285    - name: local
   286      uri: mongodb://netdata:password@localhost:27017
   287  
   288  ```
   289  </details>
   290  
   291  ##### With databases metrics
   292  
   293  An example configuration.
   294  
   295  <details><summary>Config</summary>
   296  
   297  ```yaml
   298  jobs:
   299    - name: local
   300      uri: mongodb://netdata:password@localhost:27017
   301      databases:
   302        includes:
   303          - "* *"
   304  
   305  ```
   306  </details>
   307  
   308  ##### Multi-instance
   309  
   310  > **Note**: When you define multiple jobs, their names must be unique.
   311  
   312  Local and remote instances.
   313  
   314  
   315  <details><summary>Config</summary>
   316  
   317  ```yaml
   318  jobs:
   319    - name: local
   320      uri: mongodb://netdata:password@localhost:27017
   321  
   322    - name: remote
   323      uri: mongodb://netdata:password@203.0.113.0:27017
   324  
   325  ```
   326  </details>
   327  
   328  
   329  
   330  ## Troubleshooting
   331  
   332  ### Debug Mode
   333  
   334  To troubleshoot issues with the `mongodb` collector, run the `go.d.plugin` with the debug option enabled. The output
   335  should give you clues as to why the collector isn't working.
   336  
   337  - Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
   338    your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
   339  
   340    ```bash
   341    cd /usr/libexec/netdata/plugins.d/
   342    ```
   343  
   344  - Switch to the `netdata` user.
   345  
   346    ```bash
   347    sudo -u netdata -s
   348    ```
   349  
   350  - Run the `go.d.plugin` to debug the collector:
   351  
   352    ```bash
   353    ./go.d.plugin -d -m mongodb
   354    ```
   355  
   356