docker-compose.yml
metricbeat:
container_name: metricbeat
user: root #To read the docker socket
image: docker.elastic.co/beats/metricbeat:7.11.1
logging:
options:
max-file: "3"
max-size: "50m"
volumes:
#Mount the metricbeat configuration so users can make edits.
- ./metricbeat.yml:/usr/share/metricbeat/metricbeat.yml
- ./system.yml:/usr/share/metricbeat/system.yml
#Mount the modules.d directory into the container. This allows user to potentially make changes to the modules and they will be dynamically loaded.
- ./modules.d/:/usr/share/metricbeat/modules.d/
#The commented sections below enable Metricbeat to monitor the Docker host rather than the Metricbeat container. These are used by the system module.
- /proc:/hostfs/proc:ro
- /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
#Allows us to report on docker from the hosts information.
- /var/run/docker.sock:/var/run/docker.sock:ro
#We mount the host filesystem so we can report on disk usage with the system module.
- /:/hostfs:ro
command: metricbeat -e -system.hostfs=/hostfs -strict.perms=false
restart: on-failure
metricbeat.yml
metricbeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.period: 5s
reload.enabled: true
processors:
- add_docker_metadata: ~
monitoring.enabled: true
setup.ilm.enabled: false
output.elasticsearch:
hosts: ["elasticsearch:9200"]
logging.to_files: false
setup:
kibana.host: "kibana:5601"
dashboards.enabled: true
system.yml
- module: system
metricsets:
- core
- cpu
- load
- diskio
- filesystem
- fsstat
- memory
- network
- process
- socket
enabled: true
period: 5s
processes: ['.*']
cpu_ticks: true
process.cgroups.enabled: true
process.include_top_n:
enabled: true
by_cpu: 20
by_memory: 20