https://github.com/slanatech/swagger-stats
API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
Basic Info
- Host: GitHub
- Owner: slanatech
- License: mit
- Language: JavaScript
- Default Branch: master
- Homepage: https://swaggerstats.io/
- Size: 39.2 MB
Statistics
- Stars: 923
- Watchers: 20
- Forks: 142
- Open Issues: 74
- Releases: 37
Topics
Metadata Files
README.md
swagger-stats | API Observability
https://swaggerstats.io | Guide
Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices
Express, Fastify, Koa, Hapi, Restify
swagger-stats traces REST API requests and responses in Node.js Microservices, and collects statistics per API Operation. swagger-stats detects API operations based on express routes. You may also provide Swagger (Open API) specification, and swagger-stats will match API requests with API Operations defined in swagger specification.
swagger-stats exposes statistics and metrics per API Operation, such as GET /myapi/:parameter, or GET /pet/{petId}
Built-In API Telemetry
swagger-stats provides built-in Telemetry UX, so you may enable swagger-stats in your app, and start monitoring immediately, with no infrastructure requirements. Navigate to
http://<your app host:port>/swagger-stats/

API Analytics with Elasticsearch and Kibana
swagger-stats stores details about each request/response in Elasticsearch, so you may use Kibana to perform detailed analysis of API usage over time, build visualizations and dashboards

See dashboards/elastic6 for swagger-stats Kibana visualizations and dashboards
Monitoring and Alerting with Prometheus and Grafana
swagger-stats exposes metrics in Prometheus format, so you may use Prometheus and Grafana to setup API monitoring and alerting

See dashboards/prometheus for swagger-stats Grafana dashboards
With statistics and metrics exposed by swagger-stats you may spot problematic API endpoints, see where most of errors happens, catch long-running requests, analyze details of last errors, observe trends, setup alerting.
swagger-stats provides:
* Metrics in Prometheus format, so you may use Prometheus and Grafana to setup API monitoring and alerting
* Storing details about each API Request/Response in Elasticsearch, so you may use Kibana to perform analysis of API usage over time, build visualizations and dashboards
* Built-in API Telemetry UI, so you may enable swagger-stats in your app, and start monitoring right away, with no additional tools required
* Exposing collected statistics via API, including:
* Counts of requests and responses(total and by response class), processing time (total/avg/max),
content length(total/avg/max) for requests and responses, rates for requests and errors.
This is baseline set of stats.
* Statistics by Request Method: baseline stats collected for each request method
* Timeline: baseline stats collected for each 1 minute interval during last 60 minutes. Timeline helps you to analyze trends.
* Errors: count of responses per each error code, top "not found" resources, top "server error" resources
* Last errors: request and response details for the last 100 errors (last 100 error responses)
* Longest requests: request and response details for top 100 requests that took longest time to process (time to send response)
* Tracing: Request and Response details - method, URLs, parameters, request and response headers, addresses, start/stop times and processing duration, matched API Operation info
* API Statistics: baseline stats and parameter stats per each API Operation. API operation detected based on express routes, and based on Swagger (Open API) specification
* CPU and Memory Usage of Node process
How to Use
Install
npm install swagger-stats --save
If you haven't added prom-client already, you should do this now. It's a peer dependency of swagger-stats as of version 0.95.19.
npm install prom-client@12 --save
Enable swagger-stats middleware in your app
Express
javascript
const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');
app.use(swStats.getMiddleware({swaggerSpec:apiSpec}));
Fastify
```javascript const swStats = require('swagger-stats'); const apiSpec = require('swagger.json');
const fastify = require('fastify')({ logger: true });
// Enable swagger-stats fastify.register(require('fastify-express')).then(()=>{ fastify.register(swStats.getFastifyPlugin, {swaggerSpec:apiSpec}); });
```
Koa
express-to-koa can be used which is just a simple Promise wrapper.
javascript
const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');
const e2k = require('express-to-koa');
app.use(e2k(swStats.getMiddleware({ swaggerSpec:apiSpec })));
Hapi
```javascript 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);
}; ````
Restify
```javascript const restify = require('restify'); const swStats = require('swagger-stats'); const apiSpec = require('swagger.json');
const server = restify.createServer();
server.pre(swStats.getMiddleware({ swaggerSpec:apiSpec, })); ```
See /examples for sample apps
Get Statistics with API
$ curl http://<your app host:port>/swagger-stats/stats
{
"startts": 1501647865959,
"all": {
"requests": 7,
"responses": 7,
"errors": 3,
"info": 0,
"success": 3,
"redirect": 1,
"client_error": 2,
"server_error": 1,
"total_time": 510,
"max_time": 502,
"avg_time": 72.85714285714286,
"total_req_clength": 0,
"max_req_clength": 0,
"avg_req_clength": 0,
"total_res_clength": 692,
"max_res_clength": 510,
"avg_res_clength": 98,
"req_rate": 1.0734549915657108,
"err_rate": 0.4600521392424475
},
"sys": {
"rss": 59768832,
"heapTotal": 36700160,
"heapUsed": 20081776,
"external": 5291923,
"cpu": 0
},
"name": "swagger-stats-testapp",
"version": "0.90.1",
"hostname": "hostname",
"ip": "127.0.0.1"
}
Take a look at Documentation for more details on API and returned statistics.
Get Prometheus Metrics
```
$ curl http://
HELP apiallrequest_total The total number of all API requests received
TYPE apiallrequest_total counter
apiallrequest_total 88715
HELP apiallsuccess_total The total number of all API requests with success response
TYPE apiallsuccess_total counter
apiallsuccess_total 49051
HELP apiallerrors_total The total number of all API requests with error response
TYPE apiallerrors_total counter
apiallerrors_total 32152
HELP apiallclienterrortotal The total number of all API requests with client error response
TYPE apiallclienterrortotal counter
apiallclienterrortotal 22986
. . . . . . . . . .
```
Default Metrics
To collect prom-client default metrics:
```javascript const swaggerStats = require('swagger-stats'); const promClient = require('prom-client');
promClient.collectDefaultMetrics(); ```
Some Node.js specific metrics are included, such as event loop lag:
```
HELP nodejseventlooplag_seconds Lag of event loop in seconds.
TYPE nodejseventlooplag_seconds gauge
nodejseventlooplag_seconds 0.000193641 1597303877464
. . . . . . . . . .
```
Updates
See Changelog
Enhancements and Bug Reports
If you find a bug, or have an enhancement in mind please post issues on GitHub.
License
MIT
Owner
- Name: slana.tech
- Login: slanatech
- Kind: organization
- Twitter: slanatech
- Repositories: 11
- Profile: https://github.com/slanatech
GitHub Events
Total
- Issues event: 3
- Watch event: 30
- Issue comment event: 4
- Pull request event: 2
- Fork event: 6
Last Year
- Issues event: 3
- Watch event: 30
- Issue comment event: 4
- Pull request event: 2
- Fork event: 6
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| sv2 | s****2@s****h | 373 |
| Gergely Gombos | g****g@g****m | 8 |
| Pierre Lempereur | p****r@c****m | 5 |
| dependabot[bot] | 4****] | 5 |
| Christopher Fenn | c****n@v****m | 3 |
| ramon | r****z@e****s | 2 |
| Etienne Adriaenssen | e****a@g****m | 2 |
| Kadir Goktas | k****s@g****m | 2 |
| Cole Panike | c****e@w****m | 1 |
| FHochgru | f****r@f****m | 1 |
| SaiPravesh Vishnu | S****u@e****e | 1 |
| [ESP] Aditya Aggarwal | a****a@e****m | 1 |
| davis.jaunzems | d****s@k****m | 1 |
| Ebrahim | e****h@g****m | 1 |
| Grégoire Lafitte | d****y@h****r | 1 |
| Himshwet Gaurav | hg@k****m | 1 |
| Jeff Hage | o****f@g****m | 1 |
| JustDoItSascha | s****1@g****m | 1 |
| Nas84 | 2****4 | 1 |
| Phill Garrett | g****l | 1 |
| Shubham P | s****t@s****m | 1 |
| Stephane Alnet | s****e@s****t | 1 |
| Steven Sheehy | s****y@h****m | 1 |
| Thijs Dieltjens | t****s@b****m | 1 |
| bvadell | b****l@i****s | 1 |
| ignacio.cavina | i****a@g****m | 1 |
| vonoro | 9****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 41
- Total pull requests: 86
- Average time to close issues: 2 months
- Average time to close pull requests: about 2 months
- Total issue authors: 35
- Total pull request authors: 10
- Average comments per issue: 1.78
- Average comments per pull request: 1.12
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 77
Past Year
- Issues: 6
- Pull requests: 3
- Average time to close issues: N/A
- Average time to close pull requests: 3 minutes
- Issue authors: 6
- Pull request authors: 3
- Average comments per issue: 0.17
- Average comments per pull request: 0.33
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- leedm777 (2)
- fibonacci998 (2)
- chenhuanguang (2)
- zeatful (2)
- MohammedAlasaad (1)
- AfLosada (1)
- stagefright5 (1)
- steven-sheehy (1)
- minotaurrr (1)
- deepslam (1)
- awildeep (1)
- mnajmi86 (1)
- nagarobo (1)
- rubem007 (1)
- brunolnetto (1)
Pull Request Authors
- dependabot[bot] (77)
- nautidpk (2)
- faisal00813 (2)
- Tomas2D (2)
- ramon-gonzalez (1)
- sv2 (1)
- shubhamp-sf (1)
- vonoro (1)
- angel-rs (1)
- nordluf (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 12
-
Total downloads:
- npm 149,682 last-month
- Total docker downloads: 7,157
-
Total dependent packages: 39
(may contain duplicates) -
Total dependent repositories: 319
(may contain duplicates) - Total versions: 115
- Total maintainers: 37
npmjs.org: swagger-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.99.7
published over 2 years ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/slanatech/swagger-stats
- Documentation: https://pkg.go.dev/github.com/slanatech/swagger-stats#section-documentation
- License: mit
-
Latest release: v0.99.7
published over 2 years ago
Rankings
npmjs.org: swagger-stats-lions
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.0.5
published about 7 years ago
Rankings
Maintainers (1)
npmjs.org: swagger-stats-shipsy
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.95.18
published over 5 years ago
Rankings
Maintainers (1)
npmjs.org: swagger-stats-redis
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.5.0
published about 6 years ago
Rankings
Maintainers (1)
npmjs.org: @yingpengsha/swagger-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.99.7
published about 1 year ago
Rankings
Maintainers (1)
npmjs.org: hapi-swagger-stats
Forked from https://github.com/slanatech/swagger-stats with fixed auth in hapi framework. API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open A
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.95.18
published over 5 years ago
Rankings
Maintainers (1)
npmjs.org: orion-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.5.0
published about 4 years ago
Rankings
Maintainers (1)
npmjs.org: swagger-stats-json-formatted
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 0.95.16
published almost 6 years ago
Rankings
Maintainers (1)
npmjs.org: @useparagon/swagger-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 1.0.2
published 10 months ago
Rankings
Maintainers (28)
npmjs.org: profound-swagger-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
- Status: unpublished
-
Latest release: 2.0.1
published over 1 year ago
Rankings
npmjs.org: profoundjs-swagger-stats
API Telemetry and APM. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices, based on express routes and Swagger (Open API) specification
- Homepage: http://swaggerstats.io
- License: MIT
-
Latest release: 2.0.3
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v2 composite
- github/codeql-action/analyze v1 composite
- github/codeql-action/autobuild v1 composite
- github/codeql-action/init v1 composite
- docker.elastic.co/elasticsearch/elasticsearch 5.4.2
- docker.elastic.co/kibana/kibana 5.4.2
- docker.elastic.co/elasticsearch/elasticsearch 6.2.4
- docker.elastic.co/kibana/kibana 6.2.4
- docker.elastic.co/elasticsearch/elasticsearch 7.17.8
- docker.elastic.co/kibana/kibana 7.17.8
- docker.elastic.co/elasticsearch/elasticsearch 8.6.0
- docker.elastic.co/kibana/kibana 8.6.0
- grafana/grafana latest
- prom/prometheus latest
- 527 dependencies
- @hapi/hapi ^21.1.0 development
- @hapi/inert ^7.0.0 development
- body-parser ^1.20.1 development
- chai ^4.3.7 development
- chokidar ^3.5.3 development
- concurrently ^7.6.0 development
- coveralls ^3.1.1 development
- cross-env ^7.0.3 development
- cuid ^2.1.8 development
- express ^4.18.2 development
- fastify ^4.10.2 development
- fastify-express ^0.4.0 development
- istanbul ^0.4.5 development
- mocha ^10.1.0 development
- ncp ^2.0.0 development
- nyc ^15.1.0 development
- prom-client ^14.1.0 development
- q ^1.5.1 development
- request ^2.88.2 development
- restify ^10.0.0 development
- serve-favicon ^2.5.0 development
- serve-static ^1.15.0 development
- should ^13.2.3 development
- supertest ^6.3.2 development
- swagger-parser ^10.0.3 development
- swagger-stats-ux ^0.95.29 development
- axios ^1.2.2
- basic-auth ^2.0.1
- cookies ^0.8.0
- debug ^4.3.4
- moment ^2.29.4
- path-to-regexp ^6.2.1
- qs ^6.11.0
- send ^0.18.0
- uuid ^9.0.0