gpt4 book ai didi

logging - FluentD 日志不可读。它被排除在外,下次会检查

转载 作者:行者123 更新时间:2023-12-02 11:30:32 29 4
gpt4 key购买 nike

面对:流利的日志不可读。它被排除在外,下次会检查

我有一个在 kubernetes 设置中运行的 fluentD 守护程序集的简单配置。

流利版: fluentd-0.12.43

下面是我的配置。

  <source>
@type tail
path /var/log/containers/sample*.log
time_format %Y-%m-%dT%H:%M:%S.%NZ
tag sample.*
format json
read_from_head true
</source>
<match sample.**>
@type forward
heartbeat_type tcp
send_timeout 60s
recover_wait 10s
hard_timeout 60s
<server>
name worker-node2
host 10.32.0.15
port 24224
weight 60
</server>
</match>

低于警告且不转发任何日志

2018-08-03 06:36:53 +0000 [warn]: /var/log/containers/samplelog-79bd66868b-t7xn9_logging1_fluentd-70e85c5d6328e7d.log unreadable. It is excluded and would be examined next time.

2018-08-03 06:37:53 +0000 [warn]: /var/log/containers/samplelog-79bd66868b-t7xn9_logging1_fluentd-70e85c5bc89ab24.log unreadable. It is excluded and would be examined next time.



日志文件权限:
[root@k8s-master fluentd-daemonset]# ls -lrt **/var/log/containers/**

**lrwxrwxrwx** Jun 25 06:25 sample-77g68_kube-system_kube-proxy-9f3c3951c32ee.log
-> /var/log/pods/aa1f8d5b-746f-11e8-95c0-005056b9ff3a/sample/7.log

守护程序集的 YAML 文件具有安装说明:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: fluentd
namespace: logging1
labels:
k8s-app: fluentd-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
template:
-----
-----
-----

volumeMounts:
- name: fluentd-config
mountPath: /fluentd/etc/
- name: varlog
mountPath: /var/log
readOnly: true
- name: varlogpods
mountPath: /var/log/pods
readOnly: true
- name: varlogcontainers
mountPath: /var/log/containers
readOnly: true
- name: varlibdocker
mountPath: /var/lib/docker
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: fluentd-config
configMap:
name: fluentd-config
- name: varlog
hostPath:
path: /var/log
- name: varlogpods
hostPath:
path: /var/log/pods
- name: varlogcontainers
hostPath:
path: /var/log/containers
- name: varlibdocker
hostPath:
path: /var/lib/docker
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers

即使 权限正确 , fluentD版本正确 , 挂载指令是他们在 kubernetes 守护进程中的 ,为什么我会收到此警告。

最佳答案

我遇到了类似的问题。
所以,实际发生的是——
1. Fluentd 在/var/log/containers/中创建符号链接(symbolic link),这进一步是/var/log/pods/中文件的符号链接(symbolic link),例如 -

root@fluentd-forwarders-5bfzm:/home/fluent# ls -ltr /var/log/containers/consul-0_default_consul-c4dbf47bf46b4cacfb0db67885fdba73835e05b45b14ec7dc746cc2d5ed92ea3.log 
lrwxrwxrwx. 1 root root 83 Oct 30 07:42 /var/log/containers/consul-0_default_consul-c4dbf47bf46b4cacfb0db67885fdba73835e05b45b14ec7dc746cc2d5ed92ea3.log -> /var/log/pods/default_consul-0_2a206546-73b3-4d05-bd7a-0b307c8b24d1/consul/1628.log

2./var/log/pods 是挂载在主机上的日志文件的符号链接(symbolic link)。在我的设置中,我使用主机/节点的/data/目录来存储 docker 数据。

root@fluentd-forwarders-5bfzm:/home/fluent# ls -ltr /var/log/pods/default_consul-0_2a206546-73b3-4d05-bd7a-0b307c8b24d1/consul/1629.log 
lrwxrwxrwx. 1 root root 162 Oct 30 07:47 /var/log/pods/default_consul-0_2a206546-73b3-4d05-bd7a-0b307c8b24d1/consul/1629.log -> /data/docker/containers/478642a56a6e15e7398391a2526ec52ad1aa24341e95aa32063163da11f4cc8b/478642a56a6e15e7398391a2526ec52ad1aa24341e95aa32063163da11f4cc8b-json.log

因此,在我的 deployment.yaml 中,我必须挂载/data/docker/containers 而不是/var/lib/containers/来解决问题,即

        volumeMounts:
- mountPath: /var/log
name: varlog
- mountPath: /data/docker/containers
name: datadockercontainers
readOnly: true
- mountPath: /fluentd/etc
name: config-path

关于logging - FluentD 日志不可读。它被排除在外,下次会检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51671212/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com