I would like to see in the console the time it takes for an HTTP request to be responded. Kind of like express.js does.
GET api/myurl/ 210ms 200
I run sails debug but this doesn't show much.
I have node-inspector running but it seems this lets me inspect the JavaScript objects at runtime but not this particular thing.
Is there a configuration in Sails I can enable or a NPM module I can install to find out this time between request and response?
If you want to measure total response time (including view generation and pushing data to socket) you can use req._startTime defined in startRequestTimer middleware or use response-time middleware which gives much more accurate results.
This middleware adds a X-Response-Time header to all HTTP responses so you can check it both on client and server side.
module.exports.http = {
middleware: {
order: [
'responseTimeLogger',
// ...
],
// Using built-in variable defined by Sails
responseTimeLogger: function (req, res, next) {
req.on("end", function() {
sails.log.info('response time: ' + new Date() - req._startTime + 'ms');
});
next();
},
// Using response-time middleware
responseTimeLogger: function (req, res, next) {
req.on("end", function() {
sails.log.info('response time: ' + res.getHeader('X-Response-Time'));
});
require('response-time')()(req, res, next);
}
}
}
For a more generic statistics solution (which could be used in your Sails.js project as well) there's a great series of tutorials on digitalocean on using StatsD with Graphite to measure anything (and everything) on your server: https://www.digitalocean.com/community/tutorials/an-introduction-to-tracking-statistics-with-graphite-statsd-and-collectd
There's also a nice StatsD node.js client called Lynx: https://github.com/dscape/lynx along with an express middleware for Lynx to measure counts and response times for express routes: https://github.com/rosskukulinski/lynx-express (Sails is fully compatible with Express/Connect middleware)
I'm planning to use this soon on my sails project before going to production, will update this with more details when I do, let me know if you go ahead before I do..
In addition to @abeja answer (very nice answer though), if you are looking for production application monitoring, you might be interested in New Relic.
The tool helps you to measure (among other things) response time, throughput, error rates etc.

It also measures database performance (in my case it is MongoDB) and help you easily investigate bottlenecks.

On top of that it allows you to measure application performance from a browser (including connection time, DOM rendering time etc.)
New Relic setup is very easy - a few steps to have your stats running (more here: Installing and maintaining Node.js). For development purposes you can also have free of charge account with 24hr data retention.
I hope that will also help.