In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use fluentd to collect container logs. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
In the previous ELK, we collected the logs of the Docker container using Filebeat, using the default logging driver json-file of Docker, and we will use fluentd to collect the logs of the container.
Fluentd is an open source data collector, it currently has more than 500 kinds of plugin, can connect a variety of data sources and data output components. In the next practice, Fluentd will collect the container logs and send them to Elasticsearch. The log processing process is as follows:
Here we use Filebeat to forward the logs collected by Fluentd to Elasticsearch. This is certainly not the only solution. Fluentd has a plugin fluent-plugin-elasticsearch that can send logs directly to Elasticsearch. All roads lead to Rome, and the open source world gives us a variety of possibilities to choose the right solution according to our needs.
Install Fluentd
Again, the most efficient practice is to run a fluentd container.
Docker run-d-p 24224pur24224-p 24224:24224/udp-v / data:/fluentd/log fluent/fluentd
Fluentd will receive log data on TCP/UDP port 24224, and the logs will be saved in the / data directory of Host.
Reconfigure Filebeat
Edit the Filebeat configuration file / etc/filebeat/filebeat.yml to add / data to the monitoring path.
Restart Filebeat.
Systemctl restart filebeat.service monitoring container log
Start the test container.
Docker run-d\
-- log-driver=fluentd\
-- log-opt fluentd-address=localhost:24224\
-log-opt tag= "log-test-container-A"\
Busybox sh-c 'while true; do echo "This is a log message from container A"; sleep 10; done;'
Docker run-d\
-- log-driver=fluentd\
-- log-opt fluentd-address=localhost:24224\
-log-opt tag= "log-test-container-B"\
Busybox sh-c 'while true; do echo "This is a log message from container B"; sleep 10; done;'
-- log-driver=fluentd tells Docker to use Fluentd's logging driver.
-- log-opt fluentd-address=localhost:24224 sends the container log to the data receiving port of Fluentd.
-- log-opt tag= "log-test-container-A" and-- log-opt tag= "log-test-container-B" add an optional tag to the log to distinguish between different containers.
After the container starts, Kibana will soon be able to query the container's log.
On how to use fluentd to collect container logs is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.