Create a filebeat configuation file named “filebeat.yaml”
filebeat.config:
modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
filebeat.autodiscover:
providers:
- type: docker
hints.enabled: true
processors:
- add_cloud_metadata: ~
setup.ilm:
enabled: false
output.elasticsearch:
hosts: '${ELASTICSEARCH_HOSTS:elasticsearch:9200}'
username: '${ELASTICSEARCH_USERNAME:}'
password: '${ELASTICSEARCH_PASSWORD:}'
Create a docker-compose.yaml file
version: '3.0'
services:
elasticsearch:
hostname: elasticsearch
image: elasticsearch:7.5.0
ports:
- 9200:9200
- 9300:9300
volumes:
- esdata:/usr/share/elasticsearch/data
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
kibana:
hostname: kibana
image: kibana:7.5.0
ports:
- 5601:5601
depends_on:
- elasticsearch
environment:
- XPACK_MONITORING_ENABLED=false
- LOGGING_QUIET=true
filebeat:
user: root
hostname: filebeat
image: docker.elastic.co/beats/filebeat:7.5.1
command: filebeat -e -strict.perms=false
volumes:
- ./filebeat.yaml:/usr/share/filebeat/filebeat.yml
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- output.elasticsearch.hosts=["elasticsearch:9200"]
depends_on:
- elasticsearch
volumes:
esdata:
Startup the docker containers
docker-compuse up -d
Then you can access the logs via Kibana in the browser: http://localhost:5601/