英文:
What is the best way to get Docker container logs into Elasticsearch?
问题
我有一个在容器中运行的Go应用程序,它有很多日志记录:
log.Println("Something happened!")
由于我可以通过ssh登录到运行该应用程序的服务器,我可以使用docker logs -f [id]
来查看stderr
输出,这一切都很好。
但现在我想将日志记录到Elasticsearch中。
怎样才是最好的方法呢?我看到了很多复杂的方法。
一种方法是使用GELF日志格式和Logstash,但我能找到的唯一的Go GELF格式化程序已经很老了。
或者将日志记录到文件中,然后使用Filebeat。但是我不想要跳过这个文件步骤,对吗?
英文:
I've got a Go app running in a container, and it does a lot of logging:
log.Println("Something happened!")
Since I can ssh into the server it's running on I can do docker logs -f [id]
to look at the stderr
output, that's all fine.
But now I want the logs to go into Elasticsearch.
What's the best way to do that? I've been seeing so many complicated ways to do it.
One way was to use the GELF logging format and Logstash, but the only Go GELF formatter I can find is super old.
Or log to a file and use Filebeat. But would I not want to skip that file step?
答案1
得分: 0
我会尝试使用Docker来设置Fluentd:
https://www.fluentd.org/guides/recipes/docker-logging
https://docs.docker.com/config/containers/logging/fluentd/
然后,将Fluentd配置为将日志推送到Elasticsearch:
https://docs.fluentd.org/output/elasticsearch
英文:
I would try to set up fluentd with docker:
https://www.fluentd.org/guides/recipes/docker-logging
https://docs.docker.com/config/containers/logging/fluentd/
And then make fluentd to push to elasticsearch:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论