koa-prometheus
Koa middleware to collect some metrics than you can output in prometheus format. Works with koa-router!
How to Install
$ npm install koa-prometheus
Getting Started
First use the koa-prometheus
middleware like this:
;;;// create your routerconst router = ;/* more router configuration */// create your appconst app = ;// configure middleware// this ignores requests for static assetsapp
It will collect two simple metrics for every request: How often it was requested and how long it took to respond. You can now output this in prometheus format on a different endpoint:
;{return router;}
This endpoint you can now use in combination with other prometheus-compatible tooling.
Dev stuff
How to Test
Run one, or a combination of the following commands to lint and test your code:
$ npm run lint # Lint the source code with ESLint $ npm test # Run unit tests with Mocha $ npm run test:watch # Run unit tests with Mocha, and watch files for changes $ npm run test:cover # Run unit tests with code coverage by Istanbul
To launch the documentation site, run:
$ npm install -g easystatic$ npm start
License
MIT © 2016 Nikolaus Piccolotto