swagger-stats icon indicating copy to clipboard operation
swagger-stats copied to clipboard

Usage for Docker container replicas

Open MaxVynohradov opened this issue 6 years ago • 5 comments

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)

MaxVynohradov avatar Nov 26 '19 07:11 MaxVynohradov

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)

sv2 avatar Nov 26 '19 18:11 sv2

@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?

MaxVynohradov avatar Nov 27 '19 07:11 MaxVynohradov

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 ?

sv2 avatar Nov 27 '19 18:11 sv2

Any updates on this? This would be very helpful!

chris-altamimi avatar May 19 '21 13:05 chris-altamimi

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

sv2 avatar May 19 '21 14:05 sv2