Add Metricbeat extension (#567)

Co-authored-by: Antoine Cotten <hello@acotten.com>
This commit is contained in:
Mustafa Guney
2021-01-16 23:11:24 +03:00
committed by GitHub
parent fff244e45a
commit f592f221c4
6 changed files with 184 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
ARG ELK_VERSION
FROM docker.elastic.co/beats/metricbeat:${ELK_VERSION}

View File

@@ -0,0 +1,20 @@
# Metricbeat
Metricbeat is a lightweight shipper that you can install on your servers to periodically collect metrics from the
operating system and from services running on the server. Metricbeat takes the metrics and statistics that it collects
and ships them to the output that you specify, such as Elasticsearch or Logstash.
## Usage
If you want to include the Metricbeat extension, run Docker Compose from the root of the repository with an additional
command line argument referencing the `metricbeat-compose.yml` file:
```bash
$ docker-compose -f docker-compose.yml -f extensions/metricbeat/metricbeat-compose.yml up
```
## Documentation
[Official Docs](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-overview.html)
[Running on Docker](https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-docker.html)
[Configuration reference](https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-reference-yml.html)

View File

@@ -0,0 +1,44 @@
## Metricbeat configuration
## https://github.com/elastic/beats/blob/master/deploy/docker/metricbeat.docker.yml
#
metricbeat.config:
modules:
path: ${path.config}/modules.d/*.yml
# Reload module configs as they change:
reload.enabled: false
metricbeat.autodiscover:
providers:
- type: docker
hints.enabled: true
metricbeat.modules:
- module: docker
metricsets:
- container
- cpu
- diskio
- healthcheck
- info
#- image
- memory
- network
hosts: ['unix:///var/run/docker.sock']
period: 10s
enabled: true
processors:
- add_cloud_metadata: ~
output.elasticsearch:
hosts: ['http://elasticsearch:9200']
username: elastic
password: changeme
## HTTP endpoint for health checking
## https://www.elastic.co/guide/en/beats/metricbeat/master/http-endpoint.html
#
http.enabled: true
http.host: 0.0.0.0

View File

@@ -0,0 +1,46 @@
version: '3.2'
services:
metricbeat:
build:
context: extensions/metricbeat/
args:
ELK_VERSION: $ELK_VERSION
# Run as 'root' instead of 'metricbeat' (uid 1000) to allow reading
# 'docker.sock' and the host's filesystem.
user: root
command:
# Log to stderr.
- -e
# Disable config file permissions checks. Allows mounting
# 'config/metricbeat.yml' even if it's not owned by root.
# see: https://www.elastic.co/guide/en/beats/libbeat/master/config-file-permissions.html
- --strict.perms=false
# Mount point of the hosts filesystem. Required to monitor the host
# from within a container.
- --system.hostfs=/hostfs
volumes:
- type: bind
source: ./extensions/metricbeat/config/metricbeat.yml
target: /usr/share/metricbeat/metricbeat.yml
read_only: true
- type: bind
source: /
target: /hostfs
read_only: true
- type: bind
source: /sys/fs/cgroup
target: /hostfs/sys/fs/cgroup
read_only: true
- type: bind
source: /proc
target: /hostfs/proc
read_only: true
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
read_only: true
networks:
- elk
depends_on:
- elasticsearch