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.
I have a go application running in a container that does a lot of logging:
log.Println("Something happened!")
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?
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!