MongoDB Integrations
Introduction
This integration is used to fetch logs and metrics from MongoDB.
Assumptions
The procedures described in Section 3 assumes that a Log Collector has already been setup.
Compatibility
The log dataset is tested with logs from versions v3.2.11 and v4.4.4 in plaintext and json formats. The collstats, dbstats, metrics, replstatus and status datasets are tested with MongoDB 3.4 and 3.0 and are expected to work with all versions >= 2.8.
Requirements
MongoDB Privileges
In order to use the metrics datasets, the MongoDB user specified in the package configuration needs to have certain privileges.
We recommend using the clusterMonitor role to cover all the necessary privileges.
You can use the following command in Mongo shell to create the privileged user (make sure you are using the admin db by using db command in Mongo shell).
db.createUser(
{
user: "beats",
pwd: "pass",
roles: ["clusterMonitor"]
}
)
You can use the following command in Mongo shell to grant the role to an existing user (make sure you are using the admin db by using db command in Mongo shell).
db.grantRolesToUser("user", ["clusterMonitor"])
Logs
log
The log dataset collects the MongoDB logs.
Metrics
collstats
The collstats dataset uses the top administrative command to return usage statistics for each collection. It provides the amount of time, in microseconds, used and a count of operations for the following types: total, readLock, writeLock, queries, getmore, insert, update, remove, and commands.
It requires the following privileges, which is covered by the clusterMonitor role:
-
top action on cluster resource
dbstats
The dbstats dataset collects storage statistics for a given database.
It requires the following privileges, which is covered by the clusterMonitor role:
-
listDatabases
action on cluster resource
-
for each of the databases, also need dbStats
action on the database resource
metrics
It requires the following privileges, which is covered by the clusterMonitor role:
-
serverStatus
action on cluster resource
replstatus
The replstatus dataset collects status of the replica set. It requires the following privileges, which is covered by the clusterMonitor role:
-
find/listCollections action on the local database resource
-
collStats action on the local.oplog.rs collection resource
-
replSetGetStatus action on cluster resource
status
The status returns a document that provides an overview of the database's state.
It requires the following privileges, which is covered by the clusterMonitor role:
-
serverStatus
action on cluster resource
MongoDB Integration Procedures
Please provide the following information to CyTech:
Collect MongoDB application logs
- Paths
Collect MongoDB metrics
- Hosts
Ex: localhost:27017
No Comments