What is the best way to get Docker container logs into Elasticsearch?

王林
Release: 2024-02-08 22:00:39
forward
559 people have browsed it

将 Docker 容器日志获取到 Elasticsearch 的最佳方式是什么?

php Editor Strawberry The best way to get Docker container logs to Elasticsearch is to use Filebeat. Filebeat is a lightweight log file data collector that can send Docker container logs to Elasticsearch in real time for indexing and storage. By configuring Filebeat's docker input and elasticsearch output, you can easily import Docker container logs into Elasticsearch. At the same time, Filebeat also provides a wealth of filtering and parsing options, which can process and transform logs according to needs. This method is not only simple and easy to use, but also highly efficient. It is the best choice for obtaining Docker container logs.

Question content

I have a go application running in a container that does a lot of logging:

log.Println("Something happened!")
Copy after login

Since I can ssh to the server it's running on, I can do docker logs -f [id] to see the stderr output, and it's all good.

But now I want the logs to go into elasticsearch.

What's the best way? I've seen a lot of complicated methods.

One way is to use the gelf logging format and logstash, but the only go gelf formatter I can find is very old.

Or log to a file and use filebeat. But I don't want to skip that file step?

Solution

I will try to set up Fluentd using docker:

https://www.php.cn/link/39799c18791e8d7eb29704fc5bc04ac8

https://docs.docker.com/config/containers/logging/fluent/

Then let fluidd push to elasticsearch:

https://www.php.cn/link/e0330da43b4d33f4ef9247ad260074f4

The above is the detailed content of What is the best way to get Docker container logs into Elasticsearch?. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template