Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple node.js service monitor
HTML JavaScript CSS

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

"watchmen", a service monitor for node.js

  • monitor service health (outages, uptime, response time warnings, avg. response time, etc) in your servers (http, smtp, etc).
  • use the database of your choice. Data storages are pluggable. At this time, only redis storage is available, but it is pretty easy to create and plug your own. There are plans to support couchdb and mongodb in the short term.
  • ping types are pluggable. At this time, http (includes https) and smtp (tcp connection check) are available.
  • watchmen provides customizable notifications if service is down, the response time is over a predefined limit, etc..
  • the code base aims to be small, simple and easy to understand and modify.

There is a related blog post about watchmen here.


Check the web interface in action here.

List of hosts


Watchmen depends on the following modules:

Make sure you install those dependencies:

$ npm install


a) Define hosts and services to be monitored:

You need at least one service for each host. Define the ping service type for each host or service.

Most of the properties can be defined either at host or service level. Service level properties will be prioritized.


//example of http ping for a host with 2 url's
  name:'letsnode blog',
  host: '',
  ping_interval: one_minute, //set ping interval (in seconds)
  ping_service_name: 'http', //if ping_service_name is not defined, 'http' is used by default
  failed_ping_interval: one_minute, //set ping interval if site is down (in seconds)
  enabled: true, //enables/disables this host
  alert_to: [''], //emails to alert if site goes down.
  warning_if_takes_more_than: 700, //miliseconds. alert if request takes more than this
  services : [
      name : 'home',
      method: 'get',
      url : '/',
      //expected status code and expected string to be found in the response (otherwise will fail)
      expected: {statuscode: 200, contains: 'A blog about node.js and express.js'}
    } ,
      name : 'contact page',
      method: 'get',
      url : '/contact',
      expected: {statuscode: 200, contains: 'Contact page'}
} ,

//example of smtp ping
  host: '',
  ping_interval: one_minute, //set ping interval (in seconds)
  ping_service_name: 'smtp',
  failed_ping_interval: one_minute,
  enabled: true,
  alert_to: [''], //emails to alert if site goes down.
  warning_if_takes_more_than: 700, //miliseconds. alert if request takes more than this
  services : [
      name : 'my smtp server'

Ping services


Using http ping service, you can also check for a) certain http status code or b) a certain text in the response stream.

Main properties:
  • host.port
  • host.ping_service_name (use 'http', although it is the default value)
  • service.method (get/post)
  • service.url
  • service.expected (expected status code, expected text to be found in response)


Main properties:
  • host.port
  • host.ping_service_name (use 'smtp')

 b) Define Postmark and notifications settings:

// config/general.js

module.exports.notifications = {
  enabled: false, //if disabled, no email will be sent (just console messages)
  to: '',
  postmark : {
    from: '',
    api_key : 'your-postmark-key-here'

c) Configure the storage provider

// config/storage.js

module.exports = {

  // Select storage provider.
  // Supported providers: 'redis' (only redis at this time)
  provider : 'redis',

  options : {

    // redis configuration
    'redis' : {
      port: 1216,
      host: '',
      db: 1

Storage providers


Installation and configuration
  1. get redis from
  2. launch the server:
    $ redis-server redis.conf

d) Add custom logic

Example: log in the console and send email if there is an outage:

// server.js

watchmen.on('service_error', function(service, state){

  //Do here any additional stuff when you get an error
  var info = service.url_info + ' down!. Error: ' + state.error + '. Retrying in ' +
      (parseInt(state.next_attempt_secs, 10) / 60) + ' minute(s)..';

  console.log (info);

  if (state.prev_state.status === 'success' && config.notifications.enabled){
        service.url_info + ' is down!',
        service.url_info + ' is down!. Reason: ' + error

Run watchmen

Run the monitor server

$ node server.js

or more probably you would want to use forever to run it in the background

$ forever start watchmen.js

Run the web app

$ forever start webserver/app.js 3000 #(where 3000 is the port you want to use).


Run the tests with mocha:

$ npm test


1.0.alpha1 Major changes and improvements

  • Storages are now pluggable. redis storage is used by default but you can create your own : couchdb, mongodb, text file, etc (see lib/storage).
  • Ping services are also pluggable now. So far you can use http and smtp (smtp is just checking tcp connection right now). You can create your own or improve the existent ones easily.
  • Watchmen daemon now inherits from events.EventEmitter, so you can instanciate it and subscribe to the events of your choice (service_error, service_back, etc) to implement your custom logic (see server.js).
  • Knockout.js has been removed. Watchmen uses handlebars now instead. Faster, simpler code, and avoids some client side memory leacks.
  • Client side is using moment.js for rendering dates.
  • Express.js routes now are handled on /routes
  • Mocha is used for unit testing. Mocked storages and ping services are used.
  • Configuration is now spread in separate files, under the /config directory
  • Better reporting web interface. Uptime statistics. Outages count, warnings count.


  • Major refactor, improved performance.
  • Added tests and mocked objects for testing.
  • Separate files for request, utils and watchmen library.


  • Removed logging to file.
  • Bug fixing when storing event. Needed to add port to redis key to make it unique.
  • Added callback when sending email to registered problems in delivery.


  • Targets node 0.6.x
  • Added knockoutjs for view model binding.
  • Auto async refresh main page.
  • Filter by name in main page.
  • Added counter (hosts up and down).
  • UI Improvements.
  • Tablesorter sorts status and time tags.
  • Added Google Analytics.


  • Added current status info (site is up or down) to database.
  • Added icons to display status (disable, error or ok).
  • TableSorter jQuery plugin orders by status by default.


  • Added expiration time to event records.
  • Stores avg response time for each url.
  • Warns if response time > limit.
  • Multiple recipients in notifications.
  • Removed "retry_in" option. Watchmen works in a smarter way now.
  • REDIS backend.
  • Web UI to display reports (express.js app using REDIS backend).


  • Be able to disable entries in config file at url level
  • When site is back, displays and logs information about how long the site has been down.


  • Logs "site down" and "site back up" messages to a file (logs in a different file per host)
  • Fix bug when reading url_conf.attempts on site back.


  • Allow POST method (for testing forms).
  • Added Marak/colors.js to output success and error messages.
  • Displays request duration time.
  • Refactoring.


  • First release.



  • Event pagination in service details
  • Twitter integration (pipe events to a twitter account)
  • Security (authentication for accesing the web UI and or editing stuff)
  • Google charts
  • Change configuration from control panel
  • Reset stats from control panel
  • Regular expressions support
Something went wrong with that request. Please try again.