express-prom-bundle is an Express.js middleware designed to integrate popular Prometheus metrics into an application with minimal configuration. It bundles essential metrics, notably `up` and `http_request_duration_seconds`, which can be configured as either a histogram or a summary and labeled with HTTP status codes, methods, and paths. The current stable version is 8.0.0, which requires Express.js v5 and `prom-client` v15 or higher. The library maintains a steady release cadence, incorporating dependabot updates and new features, with major versions typically aligning with peer dependency updates. A key differentiator is its focus on ease of use, providing a consolidated solution for common Express metric needs, as well as features like path normalization and custom label support. Its middleware order dependency allows for selective metric collection, and it explicitly supports both CommonJS and ESM environments, shipping with TypeScript type definitions.
npm install express-prom-bundleVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up `express-prom-bundle` with an Express application, including basic routes and custom labels, then exposes the metrics endpoint.
Upgrade your `express` installation to `express@5` (e.g., `npm install express@5 @types/express@5`) or downgrade `express-prom-bundle` to a 7.x version.
Ensure `prom-client` is installed at version `15.0.0` or higher (e.g., `npm install prom-client@^15.0.0`). For older `prom-client` versions (v12-v14), you must downgrade `express-prom-bundle` to v6.6.0.
Always place `app.use(metricsMiddleware)` before any `app.get()`, `app.post()`, etc., definitions that you wish to monitor.
Avoid changing `metricsPath` unless there's a strong, specific requirement, as it can cause confusion for standard Prometheus scraping configurations.
Run `npm install prom-client` or `yarn add prom-client` in your project.
Upgrade your `express` installation to `express@5` (e.g., `npm install express@5 @types/express@5`) or downgrade `express-prom-bundle` to a v7.x release.
Ensure that your `prom-client` installation is version `15.0.0` or higher to match the peer dependency requirements of `express-prom-bundle` v7+.
Ensure that `app.use(metricsMiddleware)` is called *before* any of the `app.get()`, `app.post()`, or other route handlers that you intend to have metrics collected for.