koa-prometheus-adv

Prometheus integration for koa

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

HomePage

https://github.com/pastjean/koa-prometheus#readme

Repository

git+https://github.com/pastjean/koa-prometheus.git


相关推荐