2.1.0 • Published 3 years ago

@sigfox/koa-prometheus-http-metrics v2.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

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.