Metricbeat monitors the CPU utilization and memory usage of the container, sends it to ElasticSearch and displays it in kibana


Metricbeat is a lightweight shipper. You can install it on the server, collect indicators from the operating system and services running on the server on a regular basis. Metricbeat obtains the indicators and statistics it collects and sends them to the output you specify, such as Elasticsearch or Logstash.

System level CPU utilization, memory, file system, disk IO and network IO statistics can be obtained, and statistics similar to the top command can be obtained for each process on the system.

Elastic Stack is required before installing Metricbeat. If not, it needs to be installed.


To download and install Metricbeat, use your system's commands (deb for Debian/Ubuntu, rpm for Redhat/Centos/Fedora, mac for OS X, docker for any docker platform, win for Windows).

I am linux centos7. There are two download methods:

1: Using rpm:

curl -L -O
sudo rpm -vi metricbeat-6.4.2-x86_64.rpm

2: Download the package:

curl -L -O
tar xzvf metricbeat-7.5.1-linux-x86_64.tar.gz

To configure:

Enable the module to run. If you accept the default configuration without enabling other modules, Metricbeat only collects system metrics.

You can enable the default module configuration defined in the modules.d directory (recommended), or you can add the module configuration to the metricbeat.yml file. The modules.d directory contains the default configuration for all available Metricbeat modules.

The following example enables apache and mysql in the directory

deb and rpm:

metricbeat modules enable apache mysql

mac and linux:

./metricbeat modules enable apache mysql

Configure vim metricbeat.yml

To configure the kibana dashboard:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
  host: ""
setup.dashboards.enabled: true

Output to ElasticSearch:

#-------------------------- Elasticsearch output ------------------------------
  # Array of hosts to connect to.
  hosts: [""]

Configure modules.d:

Configure what the container module is listening for:

[root@localhost modules.d]# vim docker.yml

# Module: docker
# Docs:

- module: docker
    - container
    - cpu
    - diskio
    - event
    - healthcheck
    - info
    - memory
    - network
  period: 10s
  hosts: ["unix:///var/run/docker.sock"]

  # If set to true, replace dots in labels with `_`.
  #labels.dedot: false

  # To connect to Docker over TLS you must specify a client and CA certificate.
    #certificate_authority: "/etc/pki/root/ca.pem"
    #certificate:           "/etc/pki/client/cert.pem"
    #key:                   "/etc/pki/client/cert.key"

Start up:

service metricbeat start
service metricbeat restart
service metricbeat status

As shown in the figure above, active (running) is displayed, indicating normal startup and no problem in configuration.

kibana visualization:

You can first check whether the startup is successful:

curl -XGET '*/_search?pretty'

OK, continue:

Website input: http://ip:5601 To view kibana's dashboard:























Published 30 original articles, won praise 15, visited 40000+
Private letter follow

Tags: Docker RPM ElasticSearch Linux

Posted on Tue, 14 Jan 2020 03:18:19 -0500 by kida462