Answer the question
In order to leave comments, you need to log in
How to collect logs from Docker containers outside of these containers?
There are microservices described in docker-compose
Everyone knows how to write logs in File, Console, ...
I want a centralized collection of logs. Let's say the same ELK (ElasticSearch, LogStash, Kibana)
If you configure the logging configuration of each microservice to log directly to Elastic or LogStash - there are no problems here, but you want to beat configuration and hard binding in a specific container for collecting logs.
I would like this scheme:
To remove logs from files that are registered as docker volume, or from stdout to pick them up somehow, and then send them to the same LogStash or Elastic. Pick up logs outside the container, not inside!
How can this be done? Does docker itself have a mechanism for sharing log files between containers, or can it read the console, because the same Kitematic shows logs from the console without problems, then it’s really possible to pull it out.
Can anyone share a working docker-compose.yml file, who has already done a similar scheme?
Answer the question
In order to leave comments, you need to log in
You can add Filebeat to your docker-compose container , for example. And use it to redirect all logs to ELK
Docker has a great ability to log messages and send them using different drivers.
https://docs.docker.com/config/containers/logging/...
One that works great with Logstash is gelf Docker
run example
run -d \
-p 80:80 \
--name nginx-logs \
--log-driver=gelf \
--log-opt gelf-address=udp://ELK-host:12201 \
--log-opt tag=site.com.ua \
nginx
If this is docker-compose, then so :
services:
nginx:
image: nginx
hostname: nginx-log
logging:
driver: gelf
options:
gelf-address: "udp://ELK-host:12201"
tag: "site.com.ua"
input {
beats {
port => 5044
}
gelf {
port => 12201
type => gelf
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question