/LogMonitor

monitoring system for logs with Node.js

Primary LanguageJavaScript

LogMonitor

A simple software for logs control. This system allows to create actions from rules, for example send an alert by email. With a config file we can set the logs on which we need a permanent listening, and link each log with a "handler".

Requirements

  • Node.js
  • NPM
  • OS Unix based

Install

We need to install the module 'emailjs' for sending emails using the handler example.

$ npm install emailjs

Now we need to rename config.json_dist:

$ mv config.json_dist config.json

Setting your logs in config.json

It is interesting to look at the parameter 'logsToTail'; through this array we can create many 'tail -f' processes as we need.

"logsToTail": [{
      "name":"_HERE_YOUR_LOG_NAME_",          
      "logFile":"_HERE_YOUR_LOG_FILE_PATH_",          
      "dataHandler" : "_HERE_YOUR_HANDLER_FILE_NAME_WITHOUT_JS_EXTENSION_"          
      }]
  • HERE_YOUR_LOG_NAME Is the unique identifier for the log that we will observe.
  • HERE_YOUR_LOG_FILE_PATH The log's path.
  • HERE_YOUR_HANDLER_FILE_NAME_WITHOUT_JS_EXTENSION Is the name of the handler that will handle the process output.

For example, if we would like to observe the logs 'dev' and 'prod' of Symfony2, our 'logsToTail' might look like this:

"logsToTail": [{   	
      "name":"xxx_dev",   	
      "logFile":"/var/www/xxx/app/logs/dev.log",   	
      "dataHandler" : "symfony2_example"   	
      },          
      {   	
      "name":"xxx_prod",   	
      "logFile":"/var/www/xxx/app/logs/prod.log",   	
      "dataHandler" : "symfony2_example"   	
      }]

For launch LogMonitor:

$ node app.js

If you need more information you can read: http://www.frontandback.org/back_end/alertas_logs_tiempo_real