All Projects → slanatech → Swagger Stats

slanatech / Swagger Stats

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Swagger Stats

Cloudprober
An active monitoring software to detect failures before your customers do.
Stars: ✭ 1,269 (+127.01%)
Mutual labels:  monitoring, devops, prometheus, grafana, observability
Netdata
Real-time performance monitoring, done right! https://www.netdata.cloud
Stars: ✭ 57,056 (+10106.8%)
Mutual labels:  monitoring, devops, prometheus, grafana, observability
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (+255.28%)
Mutual labels:  monitoring, metrics, prometheus, grafana, performance
Myperf4j
High performance Java APM. Powered by ASM. Try it. Test it. If you feel its better, use it.
Stars: ✭ 2,281 (+308.05%)
Mutual labels:  microservices, monitoring, metrics, observability, performance
Github Monitoring
Monitor your GitHub Repos with Docker & Prometheus
Stars: ✭ 163 (-70.84%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Stagemonitor
an open source solution to application performance monitoring for java server applications
Stars: ✭ 1,664 (+197.67%)
Mutual labels:  monitoring, metrics, grafana, performance
Graphite exporter
Server that accepts metrics via the Graphite protocol and exports them as Prometheus metrics
Stars: ✭ 217 (-61.18%)
Mutual labels:  monitoring, metrics, prometheus, observability
Promcord
📊 Analyze your entire discord guild in grafana using prometheus. Message, User, Game and Voice statistics...
Stars: ✭ 39 (-93.02%)
Mutual labels:  statistics, metrics, prometheus, grafana
Pingprom
Prometheus uptime monitoring quickstart
Stars: ✭ 107 (-80.86%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Mtail
extract internal monitoring data from application logs for collection in a timeseries database
Stars: ✭ 3,028 (+441.68%)
Mutual labels:  monitoring, metrics, prometheus, observability
Pyroscope
Continuous Profiling Platform! Debug performance issues down to a single line of code
Stars: ✭ 4,816 (+761.54%)
Mutual labels:  monitoring, devops, observability, performance
Heplify Server
HEP Capture Server
Stars: ✭ 110 (-80.32%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Unifiedmetrics
Fully-featured metrics collection agent for Minecraft servers. Supports Prometheus and InfluxDB. Dashboard included out-of-box.
Stars: ✭ 29 (-94.81%)
Mutual labels:  api, metrics, prometheus, grafana
Docker Traefik Prometheus
A Docker Swarm Stack for monitoring Traefik with Promethues and Grafana
Stars: ✭ 215 (-61.54%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
Stars: ✭ 45,930 (+8116.46%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Nxplorerjs Microservice Starter
Node JS , Typescript , Express based reactive microservice starter project for REST and GraphQL APIs
Stars: ✭ 193 (-65.47%)
Mutual labels:  microservices, swagger, devops, prometheus
Urlooker
enterprise-level websites monitoring system
Stars: ✭ 469 (-16.1%)
Mutual labels:  api, monitoring, devops, prometheus
Prometheus
Kubernetes Setup for Prometheus and Grafana
Stars: ✭ 824 (+47.41%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Hastic Server
Hastic data management server for analyzing patterns and anomalies from Grafana
Stars: ✭ 292 (-47.76%)
Mutual labels:  monitoring, metrics, prometheus, grafana
Kube State Metrics
Add-on agent to generate and expose cluster-level metrics.
Stars: ✭ 3,433 (+514.13%)
Mutual labels:  monitoring, metrics, prometheus, observability

swagger-stats

swagger-stats | API Observability

https://swaggerstats.io | Guide

Build Status 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/ux

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

Enable swagger-stats middleware in your app

Express

const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');
app.use(swStats.getMiddleware({swaggerSpec:apiSpec}));

Fastify

const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');

const fastify = require('fastify')({
    logger: true
});

fastify.register(swStats.getFastifyPlugin, {swaggerSpec:apiSpec});

Koa

express-to-koa can be used which is just a simple Promise wrapper.

const swStats = require('swagger-stats');
const apiSpec = require('swagger.json');
const e2k = require('express-to-koa');
app.use(e2k(swStats.getMiddleware({ swaggerSpec:apiSpec })));

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);
};

Restify

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://<your app host:port>/swagger-stats/metrics
# HELP api_all_request_total The total number of all API requests received
# TYPE api_all_request_total counter
api_all_request_total 88715
# HELP api_all_success_total The total number of all API requests with success response
# TYPE api_all_success_total counter
api_all_success_total 49051
# HELP api_all_errors_total The total number of all API requests with error response
# TYPE api_all_errors_total counter
api_all_errors_total 32152
# HELP api_all_client_error_total The total number of all API requests with client error response
# TYPE api_all_client_error_total counter
api_all_client_error_total 22986

. . . . . . . . . .  

Default Metrics

To collect prom-client default metrics:

const promClient = swaggerStats.getPromClient();
promClient.collectDefaultMetrics();

Some Node.js specific metrics are included, such as event loop lag:

# HELP nodejs_eventloop_lag_seconds Lag of event loop in seconds.
# TYPE nodejs_eventloop_lag_seconds gauge
nodejs_eventloop_lag_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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].