MongoDB is an open source, distributed database that supports high availability and horizontal scaling. It is rapidly gaining popularity in developer communities. Because of its flexibility and distributed architecture, most MongoDB production environments are configured with at least three config-server nodes, two mongos-router nodes, and one or more shards containing three or more MongoDB replicas per shard. Additional shards can be added on-the-fly if your MongoDB cluster needs horizontal scaling. As a result of this, gathering MongoDB metrics can be difficult. Not so with Wavefront’s new MongoDB dashboard. [Editor’s Note: You can try Wavefront for free here.]

MongoDB and Wavefront

While MongoDB scales as you grow, its functionality can soon become a monitoring challenge with many daunting tasks for MongoDB Admins. In addition, to ensure high scale, you need to understand the performance and availability of the MongoDB database to avoid potential latency problems, throughput bottlenecks or unanticipated infrastructure effects.

Wavefront’s SaaS-based metrics-driven analytics platform and its included MongoDB integration can help a MongoDB Admin overcome monitoring challenges helping provide proactive notifications to avoid future database performance issues.

For example, the Wavefront MongoDB integration provides detailed shard-level metrics for replication, performance metrics for WiredTiger storage, and other MongoDB performance metrics. You can combine these application performance metrics with infrastructure-level metrics in a single-pane view to quickly discover overall system health. Here is an overview and step-by-step process that describes how to configure the Wavefront Telegraf input plugin for MongoDB.

Prerequisites

• Make sure a Wavefront proxy is pre-installed and running. If not follow the instruction on how to install proxies by selecting Browse > Proxies > ADD NEW PROXY
• Verify network access between proxies and all MongoDB nodes where you will be installing the Telegraf agent.

High-level Steps

The process of configuring Wavefront Telegraf input plugin for MongoDB consist of the following three steps:

1. Install the Wavefront Telegraf Agent
2. Configure the Telegraf Input Plugin for MongoDB
3. Restart the Wavefront Telegraf Agent

Install the Wavefront Telegraf Agent

To install the Telegraf agent, click on Integrations, find and click the MongoDB tile, click the Setup tab, and follow the setup instructions.

 

Configure the Telegraf Input Plugin for MongoDB

Gather the following information prior to configuring the Telegraf input plugin:

First, make a note of bindIP and port used from all the MongoDB nodes. This information can be found in /etc/mongod.conf or /etc/mongos.conf. Here is an example of bindIP and port used in a MongoDB config server.

# network interfaces
net:
port: 27019
bindIp: localhost,10.xxx.xxx.xxx,prodmongocfg1.vmware.com

Next, create a file mongodb.conf in each MongoDB nodes inside /etc/telegraf/telegraf.d/ and copy the following snippet. Use the bindIP and port information that you obtained previously from /etc/mongod.conf.

  • If you do not want to collect db.stats metrics set gather_perdb_stats = false
  • Optional and based on your security configurations you may need to provide authentication and SSL information

# Read metrics from one or many mongodb servers

[[inputs.mongodb]]
## An array of URLs of the form:
## “mongodb://” [user “:” pass “@”] host [ “:” port]
## For example:
## mongodb://user:[email protected]:27017,
## mongodb://10.10.3.33:18832,
servers = [“mongodb://10.xxx.xxx.xxx:27019”]
##Collects metrics exposed by db.stats

gather_perdb_stats = true
## Optional SSL Config
# ssl_ca = “/etc/telegraf/ca.pem”
# ssl_cert = “/etc/telegraf/cert.pem”
# ssl_key = “/etc/telegraf/key.pem”
## Use SSL but skip chain & host verification
# insecure_skip_verify = false

Restart the Telegraf Agent

sudo service telegraf restart

A few minutes after configuration is done, you should start seeing metrics from your MongoDB nodes. To view the metrics, you can go to Browse > Sources and type your MongoDB hostname in the search field. The results will display two sets of metrics. MongoDB metrics are listed with corresponding port numbers and system-level metrics are listed by hostname.

Metrics Collected by the Wavefront MongoDB Integration

The Telegraf input plugin for MonogoDB, mainly collects MongoDB related metrics and it also collects a set of system-level metrics from host VMs and containers. To view MongoDB application metrics collected by Wavefront, go to Integrations > MongoDB. You will find a list of all collected MongoDB application metrics.

The following metrics are collected by Wavefront MongoDB integration from a MongoDB cluster, consisting of mongos routers, config servers, MongoDB shards and replica-sets.

db.stat – Metrics from databases

  • db.stats.avg.obj.size
  • db.stats.collections
  • db.stats.data.size
  • db.stats.index.size
  • db.stats.indexes
  • db.stats.num.extents
  • db.stats.objects
  • db.stats.ok
  • db.stats.storage.size

MmapStats –

  • mapped.megabytes
  • non-mapped.megabytes
  • page.fault.per.sec

WiredTigerStats – Wired Tiger Storage Engine cache metrics

  • percent.cache.dirty
  • percent.cache.used

WiredTigerExtStats – Wired Tiger Storage Engine metrics

  • wtcache.app.threads.page.read.count
  • wtcache.app.threads.page.read.time
  • wtcache.app.threads.page.write.count
  • wtcache.bytes.read.info
  • wtcache.bytes.written.from
  • wtcache.current.bytes
  • wtcache.max.bytes.configured
  • wtcache.pages.evicted.by.app.thread
  • wtcache.pages.queued.for.eviction
  • wtcache.server.evicting.pages
  • wtcache.tracked.dirty.bytes
  • wtcache.worker.thread.evicitingpages

ReplStats – Replication status metrics

  • repl.commands.per.sec
  • repl.deletes.per.sec
  • repl.getmores.per.sec
  • repl.inserts.per.sec
  • repl.lag
  • repl.queries.per.sec
  • repl.updates.per.sec

ClusterStats

  • jumbo.chunks

DefaultStats

  • inserts.per.sec
  • queries.per.sec
  • updates.per.sec
  • deletes.per.sec
  • getmores.per.sec
  • commands.per.sec
  • flushes.per.sec
  • vsize.megabytes
  • resident.megabytes
  • queued.reads
  • queued.writes
  • active.reads
  • active.writes
  • net.in.bytes
  • net.out.bytes
  • open.connections
  • ttl.deletes.per.sec
  • ttl.passes.per.sec

The Wavefront MongoDB integration also includes out-of-the-box (OOTB) dashboards where you can find all of the metrics listed above. The beauty of Wavefront is in its easy customization and the power of the Wavefront Query Language. You can clone the MongoDB OOTB dashboards and modify, add, and remove charts based on your monitoring requirements. Or, correlate MongoDB metrics with both cloud service performance metrics or custom code performance metrics for end-to-end visibility.

In addition to MongoDB application metrics, the system-level metrics from MongoDB nodes provide visibility into CPU, memory, disk, network, swap, etc. You can aggregate and correlate metrics from numerous MongoDB nodes and display them in a single pane view. Then you can proactively set alerts and avoid future problems in your MongoDB clusters by using Wavefront’s MongoDB integration. Want to try it for yourself? Check out our free trial.

Get Started with Wavefront Follow@vmw_rupesh Follow @WavefrontHQ

The post Monitor MongoDB Metrics for Better Scaling and Optimized Database Performance appeared first on Wavefront by VMware.