0

I have created a few micro services using the Moleculer framework which communicate with each other. The micro services have been deployed on different hosts using Docker Swarm.

How do I get the total number of calls that each service makes to another service as well as other metrics (like the amount of data passed between the services, bandwidth used by each service etc.)

I want to use information like total number of calls by each service to another service to decide which micro services to deploy on the same host. (e.g deploying micro services with most calls between them on a single host)

1 Answers1

2

You can use cAdvisor to monitor bandwidth usage per container and/or service. Also you can export custom metrics from your services and have Prometheus scrape both. Lastly you can issue queries to Prometheus to check call count and bandwidth of all your services.

cAdvisor read various stats from your swarm cluster (cpu, memory, bandwidth, etc) and make them available on a http endpoint. By using molecular-metrics and the prometheus module you can also expose stats about your app like memory usage, issued calls and whatever custom metric you want to in a http endpoint.

Prometheus can be configured to read from multiple metrics endpoints and store them on a time-series database so you can correlate all this data by issuing queries to it (imagine it as adatabase and you do SQL-like queries to get various stats on your cluster).

codestation
  • 2,938
  • 1
  • 22
  • 22
  • Thanks a lot. I am new to this so I don't fully understand what you mean. I will look at these three things and get back to you if I have further questions. :) – Kell Maresh Mar 22 '19 at 18:16
  • @KellMaresh i expanded a little my answer so you can get some top-level idea of the metrics generation, capture and storage. – codestation Mar 22 '19 at 18:25
  • You could check https://github.com/stefanprodan/swarmprom, this project have a pretty good instrumentation stack for docker swarm. – jmaitrehenry Mar 23 '19 at 00:11
  • @codestation I am getting metrics in Prometheus and am able to display them in Graphana as well. How can I query Prometheus for specific metrics from within a micro service? – Kell Maresh Mar 25 '19 at 16:23
  • @KellMaresh Prometheus expose a REST-like api so you can send your PromQL query to its endpoint. https://prometheus.io/docs/prometheus/latest/querying/api/ – codestation Mar 25 '19 at 16:46