Skip to content

@routup/prometheus

Collects standard HTTP metrics for every request and exposes them on a configurable scrape path. Built on prom-client, so any custom metric you register with prom-client is exported alongside the built-ins.

Built-in metrics

MetricTypeDescription
uptimegaugeTotal uptime (seconds) of the HTTP server
requestDurationhistogramPer-request duration with method, path, and status labels

Installation

bash
npm install @routup/prometheus

Quick start

typescript
import { Router, serve } from 'routup';
import { prometheus } from '@routup/prometheus';

const router = new Router();

router.use(prometheus({
    metricsPath: '/metrics',
}));

serve(router, { port: 3000 });

Scrape http://localhost:3000/metrics — Prometheus exposition format.

TIP

Install the plugin first, before any other middleware or routes you want to measure. The requestDuration histogram captures end-to-end timings, so it needs to wrap everything downstream.

See also

  • ConfigurationmetricsPath plus exposing custom prom-client metrics

Released under the MIT License.