@sigfox/koa-prometheus-http-metrics

2.1.0 • Public • Published

koa-prometheus-http-metrics

Koa middleware registering Prometheus HTTP metrics.

Features

Mount a middleware that registers HTTP metrics in the prom-client singleton and then can be easily exposed with the @sigfox/koa-prometheus package.

Install

npm install @sigfox/koa-prometheus-http-metrics

Usage

const promHttpMetrics = require('@sigfox/koa-prometheus-http-metrics');
const Koa = require('koa');

const app = new Koa().use(
  promHttpMetrics({
    filter: path => !path.includes('/admin') // remove admin routes from prometheus monitoring
  })
);
const server = app.listen();

By default the label used is the ctx.path given by Koa, if @koa-router is used ctx.routerPath will be used to group requests going to the same route. For example GET /users/1 and GET /users/2 requests matching the route /users/:id will be grouped using the label /users/:id.

Test

npm test

Licence

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @sigfox/koa-prometheus-http-metrics

Weekly Downloads

4

Version

2.1.0

License

MIT

Unpacked Size

8.26 kB

Total Files

5

Last publish

Collaborators

  • robnriks
  • cgrimal
  • damien-s
  • lbdremy