koa-prometheus-adv
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

koa-prometheus

NPM version Build Status

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

Package Sidebar

Install

npm i koa-prometheus-adv

Weekly Downloads

141

Version

1.0.1

License

MIT

Unpacked Size

16.1 kB

Total Files

6

Last publish

Collaborators

  • pastjean