express-stats
express-stats enables developers to watch their express production servers. These features are supported:
- see log files, e.g. generated by forever
- render environment specific Swagger file
- see memory usage
Getting started
Before you start provide log files in your project folder and make the logs folder writeable (chmod 700 -R logs
), e.g.:
./logs/error.log
./logs/console.log
express-stats depends on cors and ejs, so configure your Express app accordingly:
var app = require('express')(),
cors = require('cors'),
stats = require('express-stats');
var options = {
hostname: 'localhost:8080', // default to 'localhost'
logPath: __dirname + '/logs' // defaults to '/logs',
swaggerFile: 'swagger.json' //defaults to 'swagger.json'
}
app.use(cors());
app.set('views', './views');
app.engine('json', require('ejs').renderFile);
app.use(stats(options));
app.listen(8080);
Get Swagger file.
Swagger
Your swagger file should contain the variable "host": "<%- hostname %>"
, that may be generated environment specific. The following Swagger describes the provided endpoints.
swagger: "2.0"
info:
version: 0.0.1
title: your application
host: <%- hostname %>
paths:
/system/logs/{logType}:
get:
responses:
200:
description: Log file found
parameters:
- name: logType
in: path
type: string
tags:
- system
delete:
responses:
200:
description: Log file empty
parameters:
- name: logType
in: path
type: string
tags:
- system
/system/swagger:
get:
responses:
200:
description: Swagger found
tags:
- system
/system/mem:
get:
responses:
200:
description: Mem usage reported
tags:
- system
LICENSE
MIT License. Copyright 2014-2015 Oceanhouse21 GmbH. http://www.oceanhouse21.com
You are not granted rights or licenses to the trademarks of Oceanhouse21 GmbH.