Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Filebeat collects syslog logs of docker

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

docker log collection, first need to understand docker log driver type

The json-file log format is json. Default log driver

2. none does not produce logs

3. syslog writes logs to syslog, which must be running on the host

4. localLog storage in custom format for minimal overhead

5. journald Write the journal to journald

These are the most common log drivers, right? Modify docker driver type

1. Directly modify docker daemon.json file

vim /etc/docker/daemon.json

{

"log-driver": "log driver type"

"log-opts":{

"max-size": "10m",

"max-file": "3",

"labels": "xxxxxxx" }

}

2. The second type is to set the log driver type and label information of the container when the container is started.

This experiment is to collect the second way to configure the log driver type: syslog, and use filebeat collection

command operation

docker run --rm -itd --hostname test --log-driver syslog --log-opt sy-address =udp://log sent to ip:port --log-opt tag=test(label log) nignx

filebeat's profile:

vim syslog.json

filebeat.inputs:

- type: udp

host: "192.168.191.10:5144"

tags: ["syslog"]

output.file:

path: "/root/syslog"

filename: syslog.log

# rotate_every_kb: 1000

# number_of_files: 3

Start filebeat

nohup ./ filebeat -e -c syslog.json &

View log output file information

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report