Hi, 

We are starting to use Node.js here at Sematext and since eating one’s own 
dogfood is healthy, we wanted to be able to monitor our Node.js apps with 
SPM (we are in performance monitoring and big data biz). So the first thing 
we do in such a case is adding monitoring capability for technology we use 
in-house (like we did for Java, Solr, Elasticsearch, Kafka, HBase, NGINX). 

You may have seen our post about SPM for Node.js 
<http://blog.sematext.com/2015/03/30/nodejs-iojs-monitoring/> - but I 
thought I’d share a bit about how we monitor Node.js to help others facing 
the same devops needs when introducing new Node.js apps or the challenge to 
operate large deployments with a mix of technologies in the application 
stack:

1) npm i spm-agent-nodejs <https://www.npmjs.com/package/spm-agent-nodejs> 
(it’s open source on Github: sematext/spm-agent-nodejs 
<https://github.com/sematext/spm-agent-nodejs>)

2) add a new SPM App for Node.js 
<https://apps.sematext.com/spm-reports/registerApplication.do> - each 
monitored App is identified by its App-Token (and Yes - there is an API to 
automate this step)

3) set the Environment variable for the application token 
SPM_TOKEN=YOUR_TOKEN

4) add one line to the beginning of your source code (when using node.js - 
io.js got a better option/see below)
   var spmAgent = require (‘spm-agent-nodejs’)
5) Run you app and after 60 seconds you should see first metrics in SPM 

At this point what do I get?  I can see pre-defined metric charts like 
these, with about 5 minutes of work :) 

https://sematext.files.wordpress.com/2015/03/nodejs-overview-2.png

https://sematext.files.wordpress.com/2015/03/nodejs-elasticsearch-dashboard.png

I saved already time - no need to define metric queries/widgets/dashboards. 
Now i could set up alerts on Latency or Garbage Collection, or I could have 
anomaly detection tell me when the number of Workers in a dynamic queue 
changes drastically.  I typically set ‘Algolerts’ (basically machine 
learning based anomaly detection) to get notified (e.g. via PagerDuty 
<http://blog.sematext.com/2014/12/16/integrate-pagerduty-and-performance-monitoring/>)
 
when a service suddenly slows down - it produces less noise than regular 
threshold alerts. In addition I recommend to add Heartbeat alerts for each 
monitored service to be notified on any server outage or network problem. 
 In our case, where a node.js app runs tasks on Elasticsearch it makes 
sense to create custom dashboard to see Elasticsearch and Node.js metrics 
together (see 2nd screenshot above) - of course this applicable for other 
applications in the stack like Nginx, Redis or HaProxy.


Oh, and step 4) could be done even better with the* latest io.js* -- one 
could use io.js preload command-line option *without* adding the require 
statement for 'spm-agent-nodejs' to the source code:  

 iojs -r "./spm-agent-nodejs" yourApp.js

If you want to try io.js, here is how to install it: 
npm i n -g
n io 1.8 

The ‘node’ executable is now linked to ‘iojs’ - to switch back to node 0.12 
simply use 
n 0.12

I hope this helps and if you’d like to see some Node.js/io.js metrics that 
are currently not being captured by SPM -  please let me know or simply 
open an issue here: https://github.com/sematext/spm-agent-nodejs/issues

--- 
Stefan Thies <https://twitter.com/seti321/>, DevOps Evangelist @sematext 
<https://twitter.com/sematext/> Performance Monitoring * Log Analytics * 
Search Analytics Solr & Elasticsearch Support * http://sematext.com/

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/aca1a9f9-bfec-4869-944e-99bd5ff2ae07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to