MongoDB

Introduction

MongoDB is a popular open source database option that uses document-oriented data model.  Documents in MongoDB comprise sets of key-value pairs and are the basic unit of data in MongoDB.  Sets of documents are called collections and are functionally equivalent to relational database tables.

In this article, we’ll go over all necessary specific details for managing the OpsClarity - MongoDB service integration:

 

Requirements

Take note that the MongoDB user doesn’t need write access to the Database, but at a minimum he should have the “ClusterMonitor” role assigned. You can create a monitor user by running the following command:

 db.createUser({“user”:“monitor_user”, “pwd” : “test_monitor”, “roles”:[{“role”:“clusterMonitor”, “db”:“admin”}]})

Configure MongoDB Data Sources

There is one default MongoDB data source under the Configure Data Sources tab:

 

These are the field names (along with their default values) and a detailed description of what should go in each field under the MongoDB Data Source:

Field Name Default Value Description
Host 127.0.0.1

Host, localhost
Ex. localhost, 127.0.0.1
Opsclarity Magic host    _HOST:<port>_ 
Example _HOST:27017_

Port 27017 Port number
User Name empty MongoDB user name
Password empty Password for the user 
Path to Password File empty Absolute path to the Password File
Path to PemKey File empty Absolute path to the Pem key file
Path to Certificate File empty Absolute path to the Certificate file
Run as Unix User empty To run this operation as another user, populate this field.

MongoDB Default Monitors

For help with adding and configuring new monitors, click here.  There are four default monitors that are already created for you in a newly added MongoDB service:

MongoDB Metrics

These are the metrics we collect for MongoDB:

Metric Name Units Metric Description
db.admin.size Bytes Total size in bytes of the data held in this database including the padding factor.
asserts Operations Total number of internal asserts which may be issues to investigate in Mongo logs.
flushes Operations Number of background flush operations where MongoDB is writing data to disk.
flush.time Milliseconds Time spent in flush operations where MongoDB is writing data to disk.
connections.created Connections Newly created connections from clients to MongoDB.
page_faults Operations Number of memory page faults, which if sustained may indicate poor performance with data sets too large to fit in memory.
lock.time Milliseconds Time spent in global lock.
cursors.timedout Cursors Number of cursors that have timed out. This could represent an error condition in the application.
docs.deleted Documents Number of documents deleted.
docs.inserted Documents Number of documents inserted.
docs.returned Documents Number of documents returned.
docs.updated Documents Number of documents updated.
connections.service Connections Number of connections to the database server from clients, including current one, across the cluster.
connections Connections Number of connections to the database server from clients, including current one.
database.size Bytes Total size in bytes of the data held in this database including the padding factor.
connections.available Connections Number of unused incoming connections available. This can be tuned with MongoDB limits.
cursors.legacy.no_timeout Cursors Number of open cursors that have no timeout and have not yet been closed by the client. May be a resource leak.
cursors.legacy.open Cursors Number of cursors that MongoDB is maintaining for active clients. This should normally be a small value.
journal.commits Operations Number of transactions written to the journal.
journal.compression_ratio % The compression ratio of the data written to the journal.
journal.early_commits Operations Number of times Mongo requested a commit before scheduled commit interval. May indicate commit delay is too long.
journal.writes Megabytes Amount of data in megabytes written to the journal.
journal.commits.time Milliseconds Time spent in commits.
journal.commits_lock.time Milliseconds Time spent in commits under write lock. This may indicate a MongoDB node under heavy write load.
journal.prep.time Milliseconds Amount of time spent preparing to write to the journal. Smaller values indicate better journal performance.
journal.remap.time Milliseconds Time spent remapping copy-on-write memory mapped views after journaling. Smaller values indicate better performance.
journal.disk_write.time Milliseconds Time spent writing to data files after journaling. File system and device interface can affect performance.
journal.write.time Milliseconds Time spent writing to the journal. File system and device interface can affect performance.
journal.disk.writes Megabytes Amount of data in megabytes written from the journal to data files.
lock.active_clients Clients Number of active client connections to the database, both readers and writers.
lock.blocked_ops Operations Number of operations waiting for the lock.
cursors.no_timeout Cursors Number of open cursors that have no timeout and have not yet been closed by the client. May be a resource leak.
cursors.pinned Cursors Number of pinned open cursors, typically used internally for find and getMore operations. They should be unpinned at the end of the operation.
cursors.open Cursors Number of cursors that MongoDB is maintaining for active clients. This should normally be a small value.
memory.used.service Bytes Amount of RAM, in bytes, currently used by the database process, across the cluster.
memory.used Bytes Amount of RAM, in bytes, currently used by the database process.
commands.service Operations Number of commands issued to the database, across the cluster.
commands Operations Number of commands issued to the database.
deletes.service Operations Number of delete operations received, across the cluster.
deletes Operations Number of delete operations received.
getmore.service Operations Number of getmore operations received, across the cluster.
getmore Operations Number of getmore operations received.
inserts.service Operations Number of insert operations received, across the cluster.
inserts Operations Number of insert operations received.
queries.service Queries Number of queries, across the cluster.
queries Queries Number of queries.
updates.service Operations Number of update operations received per second, across the cluster.
updates Operations Number of update operations received per second. 

**
Verification**

Opsclarity MongoDB plugin, executes the following commands, to obtain mongodb metrics.

mongo –username monitor_user –password test_monitor  –eval “printjson(db.serverStatus())”
mongo –username monitor_user –password test_monitor  –eval “printjson(db.serverStatus().connections)”
mongo –username monitor_user  –password test_monitor  –eval “printjson(db.adminCommand(‘listDatabases’))”

SSL Based Authentication:

 

The options AllowInvalidCertifactes and AllowInvalidHostnames  are enabled by default.