MongoDB
Overview Copied
This is a Collection Agent plugin that gathers data from MongoDB. This plugin allows you to get an overview of database operations, such as:
- Track the current state of database.
- View reports of asserts on the database.
- Monitor the metrics for write performance.
- View contains storage statistics for a given database.
- Check reports information regarding the state and use of indexes in MongoDB.
- Monitor the state of a replica set.
Configure Geneos to deploy the MongoDB plugin Copied
The MongoDB plugin supports Collection Agent publication into Geneos using dynamic Managed Entities. Setting up this plugin in Geneos involves these primary steps:
-
Configure your other Dynamic Entities in the Gateway. See Create Dynamic Entities in Collection Agent setup for a more detailed procedure.
Set up your Collection Agent plugin Copied
Setting up your collector in the Gateway Setup Editor by adding the following configuration in Dynamic Entities > Collectors. For more information, see Collectors in Dynamic Entities.
Configuration Reference Copied
collectors:
- name: mongodb
type: plugin
className: MongoDbCollector
# Connection details
connection:
# The connection string in URI format. (required)
# Refer below for the Standard and SRV connection format.
# mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
# mongodb+srv://[username:password@]host[/[defaultauthdb][?options]]
uri: mongodb://localhost:27017/admin
# The alias that will be used to represent the connection string URI. (required)
name: MyConnectionName
# The list of Database names that will be monitored. (optional)
# If this is not defined, then the defaultauthdb in the connection URI will be monitored.
# If defaultauthdb is also not defined, then ALL databases will be monitored.
databaseNames:
- admin
- local
# Connect to a MongoDB instance using TLS
# (optional, default is connecting without tls)
tls:
# The path to a CA PEM file that contains the CA certificate. (optional)
# If this is not specified, the MongoDB Plugin will use the default Java truststore.
caFile: <path to CA PEM file>
# The path to a Client certificate. (optional)
# The mongod/mongos does not require a certificate key file from the client to verify the client's identity.
# If mongod/mongos is configured with Client Certificate Validation, clientCert and clientKey must be supplied.
clientCert: <path to Client Certificate>
# The path to a Client Key PEM File. It should be in PKCS#8 format. (optional)
clientKey: <path to Client Key PEM file>
The basic settings for using the MongoDB plugin are the connection uri
and name
. The following are sample URIs to connect to a replica set:
# mongodb://user:password@mongo1:27017,mongo2:27018,mongo3:27019,mongo4:27020,mongo5:27021/myDb?replicaSet=myReplicaSet
# mongodb+srv://replicaset.srv.com/myDb?replicaSet=myReplicaSet
The following are sample URIs to connect to a standalone server:
# mongodb+srv://user:password@standalone.srv.com/myDb
# mongodb://user:password@localhost:27027/myDb
For more information about the connection uri
, see MongoDB documentation. Additionally, include the databaseNames
to list the databases for monitoring.
For TLS-enabled MongoDB server, add the tls
configuration. Note that the client key should be in PKCS#8
format. For more information, see How to convert Client Key file to PKCS#8 format.
Configure your mappings Copied
Select one of the options listed below to configure your dynamic mappings.
- Choosing a built in mapping in Dynamic Entities > Mapping. For more information, see Mapping and mapping group in Dynamic Entities documentation.
- Setting up a custom mapping in Dynamic Entities > Mapping. For more information, see the Mapping and mapping group in Dynamic Entities documentation.
Initial Connection to MongoDB Server Copied
When all databases are monitored, specifically in cases where databaseNames
is not defined and default authentication database is not in the uri
, the complete list of databases might not be available immediately when the plugin starts. In such an instance, if the list is still unavailable, the database to be monitored will default to the source authentication database associated with the provided credentials, if it exists.
If that authentication database is not accessible, the admin
database will be used. The list of databases will be updated in the next collection time.
How to convert Client Key file to PKCS#8 format Copied
The default format of the openssl genrsa
output is in PKCS#1. To convert it to PCKS#8, execute the command:
openssl pkcs8 -topk8 -inform PEM -outform PEM -in client.key -out clientKey.pem -nocrypt
Connecting to a MongoDB Replica Set Copied
To connect to a MongoDB Replica Set, provide the necessary connection URI which can include a single or multiple replica set hosts. Additionally, the replicaSet option must be included in the connection URI.