swagger-stats
API Telemetry and APM
Express, Fastify, Koa, Hapi
Monitor API Operations, trace API requests and responses and collects metrics in Node.js microservices
Swagger / Open API
With Swagger specification provided, monitor API Operations defined in the spec
Monitoring in Seconds
Start monitoring right away using Built-In Telemetry, without any infrastructure requirements
Prometheus
Exposes metrics in Prometheus format - use Prometheus and Grafana for API monitoring and alerting
ElasticSearch
Store API request/response traces in Elasticsearch and perform detailed analysis of API usage over time
Grafana and Kibana
Analyze API traffic in Kibana and Grafana, build Visualizations and Dashboards, setup Alerting
Quick start
Install
npm install swagger-stats --save
1
Express
var swStats = require('swagger-stats');
var apiSpec = require('./swagger.json');
app.use(swStats.getMiddleware({swaggerSpec:apiSpec}));
1
2
3
4
2
3
4
Fastify
const swStats = require('swagger-stats');
const apiSpec = require('./swagger.json');
const fastify = require('fastify')({
logger: true
});
fastify.register(swStats.getFastifyPlugin, {swaggerSpec:apiSpec});
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Koa
var swStats = require('swagger-stats');
var apiSpec = require('./swagger.json');
var e2k = require('express-to-koa');
app.use(e2k(swStats.getMiddleware({ swaggerSpec:apiSpec })));
1
2
3
4
5
2
3
4
5
Hapi
const swStats = require('swagger-stats');
const swaggerSpec = require('./petstore.json');
const init = async () => {
server = Hapi.server({
port: 3040,
host: 'localhost'
});
await server.register({
plugin: swStats.getHapiPlugin,
options: {
swaggerSpec:swaggerSpec
}
});
await server.start();
console.log('Server running on %s', server.info.uri);
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20