logspout is another way to collect logs. I'm not sure this is the best solution, but it is very interesting and consistent way to collect containers containers logs. I'm not sure this is the best solution, but it is very interesting and consistent way to collect containers logs. I'm not sure this is the best solution, but it is very interesting and consistent way to collect containers magazines.
You just need to run the logspout container. This container has a function that sends docker container logs to another syslog server. (or you can also use HTTP api. see repository )
And fluentd, which runs on the host, can process these logs through syslog protocal. The following is an example of td-agent.conf. It receives the logs from syslog protocal and sends them to the elasticsearch server. (check out this sample project )
<source> type syslog port 5140 bind 0.0.0.0 tag syslog.udp format /^(?<time>.*?) (?<container_id>.*?) (?<container_name>.*?): (?<message>.*?)$/ time_format %Y-%m-%dT%H:%M:%S%z </source> <match syslog.**> index_name <ES_INDEX_NAME> type_name <ES_TYPE_NAME> type elasticsearch host <ES_HOST> port <ES_PORT> flush_interval 3s </match>
source share