WARNING: Version 5.0 of Metricbeat has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Running Metricbeat in a Container
editRunning Metricbeat in a Container
editElastic does not provide any official container images for Metricbeat. The examples on this page assume you are using your own Metricbeat container image.
When executing Metricbeat in a container, there are some important things to be aware of if you want to monitor the host machine or other containers. Let’s walk-through some examples using Docker as our container orchestration tool.
Monitoring the Host Machine
editThis example highlights the changes required to make the system module work properly inside of a container. This enables Metricbeat to monitor the host machine from within the container.
--- sudo docker run \ --volume=/proc:/hostfs/proc:ro \ --volume=/sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro \ --volume=/:/hostfs:ro \ --net=host my/metricbeat:latest -system.hostfs=/hostfs ---
Metricbeat’s system module collects much of its data through the Linux proc
filesystem, which is normally located at |
|
If you have enabled cgroup reporting (an experimental feature) from the
system process metricset, then you need to mount the host’s cgroup mountpoints
within the container. They need to be mounted inside the directory specified by
the |
|
If you want to be able to monitor filesystems from the host by using the system filesystem metricset, then those filesystems need to be mounted inside of the container. They can be mounted at any location. |
|
The system network metricset uses data from |
Monitoring a Service in Another Container
editNext let’s look at an example of monitoring a containerized service from a Metricbeat container.
Linking the containers enables Metricbeat access the exposed ports of the
mysql container, and it makes the hostname |
|
If you do not want to hardcode certain values into your Metricbeat
configuration, then you can pass them into the container either as environment
variables or as command line flags to Metricbeat (see the |
The mysql module configuration would look like this: