This is a routup plugin to collect and serve metrics for prometheus.
It provides two built-in metrics:
-
uptime
: This metric provides information about the total uptime of the http server. -
requestDuration
: This metric provides information about the duration of incoming requests.
The plugin is based on the prom-client library.
Table of Contents
npm install @routup/prometheus --save
To read the docs, visit https://routup.net
The metrics collected in the following example, can be inspected on: http://localhost:3000/metrics
The plugin should be installed before registering any other plugins or routes!
import { createServer } from 'node:http';
import { createNodeDispatcher, Router } from 'routup';
import { prometheus } from '@routup/prometheus';
const router = new Router();
router.use(prometheus({
// serve metrics on path /metrics
metricsPath: '/metrics'
}));
const server = createServer(createNodeDispatcher(router));
server.listen(3000);
Made with 💚
Published under MIT License.