Metadata-Version: 2.0
Name: datadog-mongo
Version: 1.11.0
Summary: The Mongo check
Home-page: https://github.com/DataDog/integrations-core
Author: Datadog
Author-email: packages@datadoghq.com
License: BSD
Keywords: datadog agent mongo check
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: System :: Monitoring
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Description-Content-Type: text/markdown
Requires-Dist: datadog-checks-base (>=5.1.0)

# MongoDB check

![MongoDB Dashboard][1]

## Overview

Connect MongoDB to Datadog in order to:

* Visualize key MongoDB metrics.
* Correlate MongoDB performance with the rest of your applications.

You can also create your own metrics using custom `find`, `count` and `aggregate` queries.

## Setup

Follow the instructions below to install and configure this check for an Agent running on a host. For containerized environments, see the [Autodiscovery Integration Templates][2] for guidance on applying these instructions.

### Installation

The MongoDB check is included in the [Datadog Agent][3] package, so you don't need to install anything else on your MongoDB masters.

### Configuration

Edit the `mongo.d/conf.yaml` file, in the `conf.d/` folder at the root of your [Agent's configuration directory][4] to start collecting your MongoDB [metrics](#metric-collection) and [logs](#log-collection).  See the [sample mongo.yaml][5] for all available configuration options.

#### Prepare MongoDB

In a mongo shell, create a read-only user for the Datadog Agent in the `admin` database:

```
# Authenticate as the admin user.
use admin
db.auth("admin", "<YOUR_MONGODB_ADMIN_PASSWORD>")

# On MongoDB 2.x, use the addUser command.
db.addUser("datadog", "<UNIQUEPASSWORD>", true)

# On MongoDB 3.x or higher, use the createUser command.
db.createUser({
  "user":"datadog",
  "pwd": "<UNIQUEPASSWORD>",
  "roles" : [
    {role: 'read', db: 'admin' },
    {role: 'clusterMonitor', db: 'admin'},
    {role: 'read', db: 'local' }
  ]
})
```

#### Metric collection

* Add this configuration block to your `mongo.d/conf.yaml` file to start gathering your [MongoDB Metrics](#metrics):

  ```
  init_config:
  instances:
    - server: mongodb://datadog:<UNIQUEPASSWORD>@localhost:27017/admin
      additional_metrics:
        - collection       # collect metrics for each collection
        - metrics.commands
        - tcmalloc
        - top
  ```
  See the [sample mongo.yaml][5] for all available configuration options, including those for custom metrics.

* [Restart the Agent][6] to start sending MongoDB metrics to Datadog.

#### Log collection

**Available for Agent >6.0**

1. Collecting logs is disabled by default in the Datadog Agent, enable it in your `datadog.yaml` file:

    ```yaml
      logs_enabled: true
    ```

2. Add this configuration block to your `mongo.d/conf.yaml` file to start collecting your MongoDB Logs:

    ```yaml
      logs:
          - type: file
            path: /var/log/mongodb/mongodb.log
            service: mongo
            source: mongodb
    ```
    Change the `service` and `path` parameter values and configure them for your environment.
    See the [sample mongo.yaml][5] for all available configuration options

3. [Restart the Agent][6].

### Validation

[Run the Agent's status subcommand][8] and look for `mongo` under the Checks section.

## Data Collected
### Metrics

See [metadata.csv][9] for a list of metrics provided by this check.

See the [MongoDB 3.0 Manual][10] for more detailed descriptions of some of these metrics.

**NOTE**: The following metrics are NOT collected by default:

|                          |                                                   |
| ---                      | ---                                               |
| metric prefix            | what to add to `additional_metrics` to collect it |
| mongodb.collection       | collection                                        |
| mongodb.commands         | top                                               |
| mongodb.getmore          | top                                               |
| mongodb.insert           | top                                               |
| mongodb.queries          | top                                               |
| mongodb.readLock         | top                                               |
| mongodb.writeLock        | top                                               |
| mongodb.remove           | top                                               |
| mongodb.total            | top                                               |
| mongodb.update           | top                                               |
| mongodb.writeLock        | top                                               |
| mongodb.tcmalloc         | tcmalloc                                          |
| mongodb.metrics.commands | metrics.commands                                  |

### Events

**Replication state changes**:<br>
This check emits an event each time a Mongo node has a change in its replication state.

### Service Checks

**mongodb.can_connect**:<br>
Returns `CRITICAL` if the Agent cannot connect to MongoDB to collect metrics, otherwise returns `OK`.

## Troubleshooting
Need help? Contact [Datadog support][11].

## Further Reading
Read our series of blog posts about collecting metrics from MongoDB with Datadog:

* [Monitoring MongoDB performance metrics (WiredTiger)][12]
* [Monitoring MongoDB performance metrics (MMAP)][13]


[1]: https://raw.githubusercontent.com/DataDog/integrations-core/master/mongo/images/mongo_dashboard.png
[2]: https://docs.datadoghq.com/agent/autodiscovery/integrations
[3]: https://app.datadoghq.com/account/settings#agent
[4]: https://docs.datadoghq.com/agent/guide/agent-configuration-files/?tab=agentv6#agent-configuration-directory
[5]: https://github.com/DataDog/integrations-core/blob/master/mongo/datadog_checks/mongo/data/conf.yaml.example
[6]: https://docs.datadoghq.com/agent/guide/agent-commands/?tab=agentv6#start-stop-and-restart-the-agent
[8]: https://docs.datadoghq.com/agent/guide/agent-commands/?tab=agentv6#agent-status-and-information
[9]: https://github.com/DataDog/integrations-core/blob/master/mongo/metadata.csv
[10]: https://docs.mongodb.org/manual/reference/command/dbStats
[11]: https://docs.datadoghq.com/help
[12]: https://www.datadoghq.com/blog/monitoring-mongodb-performance-metrics-wiredtiger
[13]: https://www.datadoghq.com/blog/monitoring-mongodb-performance-metrics-mmap


