我使用的是启动我的服务的docker-compose.yml。所有服务看起来都是这样的:
A-service:
image: A-service
restart: always
network_mode: host
logging:
driver: journald
options:
tag: "{{.ImageName}}/{{.Name}}/{{.ID}}"
fluent-bit:
image: 'bitnami/fluent-bit:latest'
restart: always
network_mode: host
command: /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf
volumes:
- ./service/config/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
- type: bind
source: /run/log
target: /run/log当我运行journalctl -e -f -u docker时,我会看到所有日志都被记录得很好。我遇到的问题是,当从systemd收集数据时,我的fluent位容器似乎无法获得任何数据:
fluent-bit.conf:
[SERVICE]
Flush 5
Daemon Off
Log_Level debug
[INPUT]
Name systemd
Tag *
[OUTPUT]
Name stdout
Match *我认为这可能是因为它位于容器中,无法到达日志位置,但是绑定目录/run/log:/run/log没有任何效果。
因此,我的问题是:当系统在容器内时,流利的位是否能够到达系统并阅读日记?如果是-我怎样才能做到这一点?
发布于 2020-10-13 11:19:13
在进行了更多的研究后,我无意中发现了这条线索:https://github.com/fluent/fluent-bit/issues/497
长话短说:
/run/log/journal:/run/log/journal
因此:
fluent-bit:
image: 'bitnami/fluent-bit:latest'
restart: always
user: root
network_mode: host
command: /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf
volumes:
- ./service/config/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
- /etc/machine-id:/etc/machine-id:ro
- /run/log/journal:/run/log/journal然后,在fluent-bit.conf中,需要编辑输入路径:
[INPUT]
Name systemd
Tag *
Path /run/log/journal
Systemd_Filter _SYSTEMD_UNIT=docker.service
Systemd_Filter _SYSTEMD_UNIT=kubelet.servicehttps://stackoverflow.com/questions/64333292
复制相似问题