# How to use Metricbeat to monitor Docker Swarm containers, hosts and external services

**URL:** https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037
**Category:** Beats
**Tags:** docker, metricbeat
**Created:** [December 9, 2018, 9:33am UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037 "2018-12-09T09:33:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hamid.haghshenas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamid.haghshenas/32/42667_2.png) [@hamid.haghshenas](https://discuss.elastic.co/u/hamid.haghshenas)
#### Post date: [December 9, 2018, 9:33am UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037/1 "2018-12-09T09:33:28Z")

</div>

We need to monitor:

- a number of Docker Swarm services, each may have multiple containers on multiple hosts (A host may run several containers of the same service),
- hosts running Docker Swarm, and
- Some external services like MySQL which are not on Docker Swarm

**First question:**

I've read in other topics to run an instance of Metricbeat on each host. But, can I monitor all the above with one metricbeat service with `mode: global` (i.e., one container per host)?

Assuming the answer is "no" and I cannot monitor MySQL with such a setting, I decided to have two Swarm services: `metricbeat_node` and `metricbeat_single`. The former runs with `mode: global` and has system and docker modules. The latter is a singleton service and has mysql module. If I'm wrong, what should I do for this?

**Second question:**

If the above settings is accepted, then which of the two Metricbeat services should monitor other Swarm services? Say, I have a service `my_app` running uWSGI and may have many replicas. Is it better to monitor it using `metricbeat_node` (i.e., monitor each host's containers with a Metricbeat container running on that host), or `metricbeat_single` (i.e., monitor all of them centrally)? Which is better and why?

---

<div class="post-metadata">

### Author: ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)
#### Post date: [December 10, 2018, 1:28pm UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037/2 "2018-12-10T13:28:21Z")

</div>

It's recommend to run your Metricbeat container as a side car and mount the correct volumes: [https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html](https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html) If you do that, you can monitor all services form 1 container + the host + the containers.

---

<div class="post-metadata">

### Author: ![hamid.haghshenas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamid.haghshenas/32/42667_2.png) [@hamid.haghshenas](https://discuss.elastic.co/u/hamid.haghshenas)
#### Post date: [December 10, 2018, 2:41pm UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037/3 "2018-12-10T14:41:36Z")

</div>

Thanks @ruflin; I read your answer multiple times and read the link you provided completely, but didn't get the point.

By 'side car' do you mean that I need separate Metricbeat containers for monitoring different thins? That is, I need one Metricbeat container on each node to monitor the hosts, another container to monitor my external MySQL, another set of containers to monitor NGINX, Redis, etc.?

---

<div class="post-metadata">

### Author: ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)
#### Post date: [December 13, 2018, 8:20am UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037/4 "2018-12-13T08:20:02Z")

</div>

You need only 1 container per docker host to monitor the host, all containers and the services inside. So if you have host machines, you will need 3 metricbeat instances.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 10, 2019, 8:33am UTC](https://discuss.elastic.co/t/how-to-use-metricbeat-to-monitor-docker-swarm-containers-hosts-and-external-services/160037/5 "2019-01-10T08:33:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
