Swagger-stats is a Node.js library for API telemetry and Application Performance Monitoring (APM). It traces REST API calls and responses, collecting performance, health, and usage statistics per API operation. It supports popular Node.js frameworks including Express, Fastify, Koa, Hapi, and Restify, detecting API operations based on Express routes or an optional OpenAPI (Swagger) specification. Key differentiators include a built-in telemetry UI for immediate monitoring, out-of-the-box integration with Prometheus/Grafana for monitoring and alerting, and Elasticsearch/Kibana for detailed API analytics. The current stable version is 0.99.7, indicating it's actively developed and approaching a 1.0 release, with a cadence of regular bug fixes and dependency updates, alongside occasional feature enhancements. It provides granular metrics to identify problematic endpoints, errors, and performance bottlenecks.
npm install swagger-statsVerified import paths — ran on the pinned version, not inferred.
Sets up an Express application with swagger-stats middleware, exposing basic API telemetry, a built-in UI, and Prometheus metrics.
Install `prom-client` manually: `npm install prom-client` or `yarn add prom-client`. Ensure its version is within the `>=10 <=14` range specified by swagger-stats.
No direct fix for user code, but be aware that if your project had implicit dependencies or complex module resolution tied to `request` being present, this change could subtly affect that setup. Ensure `axios` is compatible within your environment.
Review your `swagger-stats` configuration related to UI customization. If you relied on specific DOM structures or CSS classes for custom branding/integration, these might require updates. Consult the latest documentation for UX configuration options.
If using Elasticsearch for API analytics, review your Kibana visualizations and queries after upgrading to ensure compatibility with the new `flattened` data type. Update existing dashboards as needed, particularly those inspecting request/response body content.
Run `npm install prom-client` or `yarn add prom-client` in your project directory.
This issue was specifically addressed in `v0.99.2`. Upgrade `swagger-stats` to `0.99.2` or later to leverage performance improvements for the UI.
Upgrade to `swagger-stats` `0.95.18` or later. This version introduces support for Elasticsearch 7.X `flattened` data types, which addresses this issue and improves storage efficiency. Re-index or clear old data in Elasticsearch if needed.
Upgrade to `swagger-stats` `0.99.1` or later, as several authentication-related bugs were fixed in this release, including Hapi-specific issues and general UI protection.