koa-prometheus-adv
v1.0.1
Published
Prometheus integration for koa
Downloads
587
Maintainers
Readme
koa-prometheus
Installation
npm install -i koa-prometheus-adv prom-client
Usage
Complete example 😀
const koa = require('koa');
const prom = require('prom-client');
const koaPrometheus = require('koa-prometheus-adv');
const app = new Koa();
app.use(koaPrometheus.DefaultHTTPMetricsInjector(prom.registry))
.use(async (ctx) => {
if(ctx.request.method === 'GET' && ctx.request.url === '/metrics') {
return await koaPrometheus.metricsHandler(ctx);
}
ctx.status = 200;
ctx.body = 'koa 💛 prometheus';
})
License
MIT