https://github.com/slanatech/swagger-stats

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.

https://github.com/slanatech/swagger-stats

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

api api-telemetry collects-statistics devops exposes-statistics grafana kibana metrics microservices monitoring nodejs observability performance prometheus rest statistics swagger swagger-stats

Keywords from Contributors

sequences projection interactive serializer measurement cycles packaging charts network-simulation archival
Last synced: 5 months ago · JSON representation

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
api api-telemetry collects-statistics devops exposes-statistics grafana kibana metrics microservices monitoring nodejs observability performance prometheus rest statistics swagger swagger-stats
Created almost 9 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Changelog Contributing Funding License

README.md

swagger-stats

swagger-stats | API Observability

https://swaggerstats.io | Guide

CircleCI Coverage Status npm version npm downloads Gitter

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/

swagger-stats Built-In Telemetry

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

swagger-stats Kibana Dashboard

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

swagger-stats Prometheus Dashboard

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:///swagger-stats/metrics

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

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

All Time
  • Total Commits: 419
  • Total Committers: 27
  • Avg Commits per committer: 15.519
  • Development Distribution Score (DDS): 0.11
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

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
enhancement (10) question (9) bug (6) doc (2)
Pull Request Labels
dependencies (77)

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

  • Versions: 39
  • Dependent Packages: 31
  • Dependent Repositories: 314
  • Downloads: 125,413 Last month
  • Docker Downloads: 7,157
Rankings
Downloads: 0.7%
Docker downloads count: 0.8%
Dependent packages count: 0.9%
Dependent repos count: 0.9%
Average: 1.5%
Stargazers count: 2.6%
Forks count: 2.8%
Maintainers (1)
sv2
Last synced: 6 months ago
proxy.golang.org: github.com/slanatech/swagger-stats
  • Versions: 37
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 2.2%
Forks count: 2.4%
Average: 6.2%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 7 months ago
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

  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 5
  • Downloads: 5 Last month
Rankings
Stargazers count: 2.5%
Forks count: 2.7%
Dependent repos count: 5.0%
Average: 12.6%
Dependent packages count: 20.9%
Downloads: 31.9%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 227 Last month
Rankings
Stargazers count: 3.1%
Forks count: 3.3%
Average: 13.5%
Dependent packages count: 16.2%
Downloads: 19.4%
Dependent repos count: 25.3%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 5 Last month
Rankings
Stargazers count: 3.1%
Forks count: 3.3%
Average: 15.5%
Dependent packages count: 16.2%
Dependent repos count: 25.3%
Downloads: 29.7%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 4 Last month
Rankings
Stargazers count: 2.0%
Forks count: 2.2%
Average: 16.5%
Dependent repos count: 25.3%
Dependent packages count: 36.6%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 3 Last month
Rankings
Stargazers count: 3.1%
Forks count: 3.3%
Dependent packages count: 16.2%
Average: 18.8%
Dependent repos count: 25.3%
Downloads: 45.8%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 4 Last month
Rankings
Stargazers count: 3.1%
Forks count: 3.3%
Dependent packages count: 16.2%
Average: 18.8%
Dependent repos count: 25.3%
Downloads: 45.8%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 23 Last month
Rankings
Stargazers count: 3.1%
Forks count: 3.3%
Dependent packages count: 16.2%
Average: 19.8%
Dependent repos count: 25.3%
Downloads: 51.2%
Maintainers (1)
Last synced: 7 months ago
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

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 23,538 Last month
Rankings
Dependent repos count: 24.7%
Downloads: 24.9%
Average: 28.4%
Dependent packages count: 35.6%
Last synced: 6 months ago
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
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 25.8%
Average: 31.6%
Dependent packages count: 37.5%
Last synced: 7 months ago
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

  • Versions: 16
  • Dependent Packages: 2
  • Dependent Repositories: 0
  • Downloads: 460 Last month
Rankings
Dependent packages count: 16.2%
Dependent repos count: 25.3%
Average: 33.2%
Downloads: 58.0%
Maintainers (1)
Last synced: 7 months ago

Dependencies

.github/workflows/codeql-analysis.yml actions
  • actions/checkout v2 composite
  • github/codeql-action/analyze v1 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v1 composite
scripts/elasticsearch/elastic5/docker-compose.yml docker
  • docker.elastic.co/elasticsearch/elasticsearch 5.4.2
  • docker.elastic.co/kibana/kibana 5.4.2
scripts/elasticsearch/elastic6/docker-compose.yml docker
  • docker.elastic.co/elasticsearch/elasticsearch 6.2.4
  • docker.elastic.co/kibana/kibana 6.2.4
scripts/elasticsearch/elastic7/docker-compose.yml docker
  • docker.elastic.co/elasticsearch/elasticsearch 7.17.8
  • docker.elastic.co/kibana/kibana 7.17.8
scripts/elasticsearch/elastic8/docker-compose.yml docker
  • docker.elastic.co/elasticsearch/elasticsearch 8.6.0
  • docker.elastic.co/kibana/kibana 8.6.0
scripts/prometheus/docker/docker-compose.yml docker
  • grafana/grafana latest
  • prom/prometheus latest
package-lock.json npm
  • 527 dependencies
package.json npm
  • @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