{"id":25776,"date":"2015-08-31T17:38:10","date_gmt":"2015-08-31T12:08:10","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=25776"},"modified":"2015-12-16T12:32:25","modified_gmt":"2015-12-16T07:02:25","slug":"monitoring-mongodb-using-newrelic","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/monitoring-mongodb-using-newrelic\/","title":{"rendered":"Monitoring MongoDB using New Relic"},"content":{"rendered":"<p style=\"text-align: justify\"><strong>Scope<\/strong><\/p>\n<p style=\"text-align: justify\">This blog illustrates advantages of New Relic over different monitoring strategies and step by step method to configure new relic plugin for mongoDB.<\/p>\n<p><strong>What is New Relic?<\/strong><\/p>\n<p>New Relic is a SaaS\u00a0model (Software as a service) that provides capabilities to monitor applications in real-time.<\/p>\n<p><strong>Why I chose New Relic\u00a0to monitor MongoDB over different monitoring strategies? <\/strong><\/p>\n<p>1.\u00a0 Utilities such as\u00a0<strong>mongostat, mongotop<\/strong> are used for immediate results. They do not give us a trend over time in a graphical manner on a visual dashboard.<\/p>\n<p>2. These utilities require us to login to the DB instances, whereas\u00a0New Relic plugins exempt us from this.<\/p>\n<p>3. Advanced features such as alerts are not supported by these utilities.<\/p>\n<p>4.\u00a0 As compared to self-hosted monitoring tools like &#8216;Nagios&#8217;, New Relic has several advantages:-<\/p>\n<ul>\n<li>Since New Relic is based on Saas model it frees us from overheads of infrastructure management and high availability concepts.<\/li>\n<li style=\"text-align: justify\">New Relic provides multiple monitoring parameters such as Operations per second, Transactions, queries by default whereas we need to configure each parameter in Nagios.<\/li>\n<\/ul>\n<h3><span style=\"text-decoration: underline\"><strong>Demo Setup<\/strong><\/span><\/h3>\n<p><strong>Installation and Configuration Steps:-<br \/>\nNote:<\/strong> These steps are performed on Ubuntu machine:-<\/p>\n<ul>\n<li>Download the latest release of new relic plugin for MongoDB from GitHub(<a title=\"GitHub Link\" href=\"https:\/\/github.com\/MongoHQ\/newrelic-mongodb-agent\/releases\">Link<\/a>).<\/li>\n<li>Move config\/template_newrelic_plugin.yml to config\/newrelic_plugin.yml<\/li>\n<li>\u00a0Modify different configuration parameters in newrelic_plugin.yml (license_key, agent_name, username and password)<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-25956\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/08\/cffffgggg.png\" alt=\"cffffgggg\" width=\"827\" height=\"202\" \/><\/p>\n<ul>\n<ul>\n<li>New Relic\u00a0provides a license when you sign up. You need to provide the same in the configuration file.<\/li>\n<li>To install\u00a0the gems listed in Gemfile run <strong>bundle install.<\/strong><\/li>\n<li>Foreman is used to manage\u00a0Procfile-based applications, foreman start is used to run your application directly from the command line, Run <strong>foreman start.<\/strong><\/li>\n<li>Login to your\u00a0New Relic account.<\/li>\n<li>Go to <strong>Plugins Tab.<\/strong><\/li>\n<li>\u00a0You can see your agent name on the console.<\/li>\n<\/ul>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-25924\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/08\/Agent_name.png\" alt=\"Agent_name\" width=\"844\" height=\"145\" \/><\/p>\n<ul>\n<ul>\n<li>Click on agent name to see monitoring graphs overview for your agent.<\/li>\n<\/ul>\n<\/ul>\n<p>For the demo, I have run a query that inserts 10000 collections in the database.<\/p>\n<p>[js]<br \/>\nvar insertT = function() {<br \/>\n    var start = (new Date()).getTime();<br \/>\n    for (var i=0; i&lt; 10000; i++) {<br \/>\n        db.task1.insert({&quot;user&quot; : &quot;Coldsky&quot;, &quot;finished&quot; : i, &quot;unfinished&quot; : 1000000 &#8211; i})<br \/>\n    }<br \/>\n   var end  = (new Date()).getTime();<br \/>\n    var diff = end -start;<br \/>\n     print(&quot;Insert 1M documents took &quot; + diff + &quot;ms&quot; )<br \/>\n     }<br \/>\ninsertT()<br \/>\n[\/js]<\/p>\n<p>The plugin <strong>newrelic-mongodb-agent <\/strong>installed will monitor following metrics by default:-<\/p>\n<ul>\n<li><strong>Operations\/Second:<\/strong> It reflects average operations (<tt class=\"descname\">query<\/tt>, <tt class=\"descname\">update<\/tt>, <tt class=\"descname\">delete<\/tt>, etc) per second.<\/li>\n<li><strong>RAM Usage: <\/strong>The amount of available RAM should be working set size, the size of indexes, rest of the OS, other software running on the same machine.<\/li>\n<li><strong>Disk Size<\/strong>: % of disk space used by the collections.<strong><br \/>\n<\/strong><\/li>\n<li><strong>Lock%:<\/strong> It represents the total amount of time spent in write lock. This value increase when more write operations (updates, inserts, deletions) are done on the database.<\/li>\n<li><strong>Page Faults:\u00a0<\/strong>Page faults can occur as MongoDB reads from or writes data to parts of its data files that are not currently located in physical memory.<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> It takes up to 5 minutes for\u00a0New Relic to show graphs.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-25862\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/08\/pagefaults.png\" alt=\"pagefaults\" width=\"725\" height=\"251\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-25863\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/08\/Screenshot-from-2015-08-31-131817.png\" alt=\"Screenshot from 2015-08-31 13:18:17\" width=\"724\" height=\"439\" \/><\/p>\n<p>In this blog, I have talked about one of the plugins offered by New Relic for monitoring mongoDB. Similarly, you can choose a different plugin based on the default metrics it offers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scope This blog illustrates advantages of New Relic over different monitoring strategies and step by step method to configure new relic plugin for mongoDB. What is New Relic? New Relic is a SaaS\u00a0model (Software as a service) that provides capabilities to monitor applications in real-time. Why I chose New Relic\u00a0to monitor MongoDB over different monitoring [&hellip;]<\/p>\n","protected":false},"author":214,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":15},"categories":[1],"tags":[4846,1499],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/25776"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/214"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=25776"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/25776\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=25776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=25776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=25776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}