slanatech / swagger-stats

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
https://swaggerstats.io/
MIT License
886 stars 136 forks source link

Usage for Docker container replicas #82

Open MaxVynohradov opened 4 years ago

MaxVynohradov commented 4 years ago

Hi! Great Tool, thanks!

Have you any guide how to configure swagger-stats for docker containers replicas? I'm going to use it with AWS ECS tasks - imagine when you have your express server in few instances and load balancer over them, like PM2 but in different docker containers. How do you think - is it possible and in what way?

(https://docs.aws.amazon.com/en_us/AmazonECS/latest/developerguide/ecs_services.html) (scheme https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.systems-plus.com%2Fdeploying-restful-microservices-as-docker-containers-in-ecs-fargate%2F&psig=AOvVaw0-cYaaN_YUH_hmHAFhNtGo&ust=1574839248969000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCLCx78arh-YCFQAAAAAdAAAAABAV)

sv2 commented 4 years ago

Hi! Thanks ! This is where support for ElasticSearch and Prometheus comes in. Indeed, when running in production, you would most likely have N+1 configuration - multiple nodes behind LB, i.e. as you referred - set of ECS tasks behind ALB in AWS. In this case, you need to collect api usage data from all nodes in one datastore so you can analyze across all nodes. You can enable Elasticsearch in swagger-stats config, so each node of your app would store api usage traces in Elasticsearch. Then you can use Kibana to analyze data and build dashboards. Or you can use Prometheus to scrape api usage metrics from all the nodes of your app (tasks) - swagger-stats exposed Prometheus metrics. Then you can use Gafana to analyze api metrics data in Prometheus (see https://swaggerstats.io/guide/prometheus.html)

MaxVynohradov commented 4 years ago

@sv2 Got this, thanks. But what about your pretty ui? Do you have any trick to observe metrics from the several nodes on it? You know, at least like temporary solution for project start?

sv2 commented 4 years ago

Not yet, but thinking about it ... What I have in mind - package UI and simple backend into separate app (docker image). This app would query stats from all the nodes with swagger-stats enabled, and show consolidated stats in UI. You would then be able to run it alongside with your app nodes, for example, as separate service/task in AWS ECS. What do you think ? Would you be interested to beta-test it ?

chris-altamimi commented 3 years ago

Any updates on this? This would be very helpful!

sv2 commented 3 years ago

Envision this to be a part of 1.X release: https://github.com/slanatech/swagger-stats/discussions/135 Comments and discussions are very welcome !