本文介绍了FluentBit不从共享PVC读取日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有ReadWriteMany(RWX)访问模式的PersistentVolumeClaims(PVC)。这个聚氯乙烯是由两个吊舱夹住的。在第二个Pod中,我让FluentBit读取共享PVC中应用程序Pod存储的日志。问题是FluentBit识别文件。FluentBit将发现新文件的信息打印到日志中。但它不读取新文件的内容以及日志插入文件的方式。
我正在使用OpenShift 3.11,如果这有什么不同的话。如何在Pod之间共享PVC?
来自fluentBit控制台的日志。
Fluent Bit v1.7.9
* Copyright (C) 2019-2021 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io
[2021/07/21 08:20:09] [ info] [engine] started (pid=1)
[2021/07/21 08:20:09] [ info] [storage] version=1.1.1, initializing...
[2021/07/21 08:20:09] [ info] [storage] in-memory
[2021/07/21 08:20:09] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
[2021/07/21 08:20:09] [ info] [http_server] listen iface=0.0.0.0 tcp_port=2020
[2021/07/21 08:20:09] [ info] [sp] stream processor started
[2021/07/21 08:20:09] [ info] [input:tail:tail.0] inotify_fs_add(): inode=97 watch_fd=1 name=/var/log/log-logging-poc-standalone-app-54d8467d6f-f9j5c-2021072011.json
[2021/07/21 08:20:09] [ info] [input:tail:tail.0] inotify_fs_add(): inode=54346 watch_fd=1 name=/var/log/log-logging-poc-standalone-app-54d8467d6f-f9j5c-2021072012.json
[2021/07/21 08:20:09] [ info] [input:tail:tail.0] inotify_fs_add(): inode=43255 watch_fd=1 name=/var/log/log-logging-poc-standalone-app-54d8467d6f-f9j5c-2021072013.json
First-应用程序Pod声明这是用来存储应用程序日志的。
apiVersion: apps/v1
kind: Deployment
metadata:
name: logging-poc-standalone-app
spec:
selector:
matchLabels:
app: logging-poc-standalone-app
template:
metadata:
labels:
app: logging-poc-standalone-app
spec:
containers:
- name: logging-poc-standalone-app
image: loggingpoc:dev
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8080
volumeMounts:
- name: log-volume
mountPath: /var/log/
securityContext:
supplementalGroups: [100003]
privileged: false
volumes:
- name: log-volume
persistentVolumeClaim:
claimName: data-3
Second-FluentBit Pod在只读模式下声明相同的PVC。
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluent-bit
spec:
selector:
matchLabels:
app: fluent-bit
template:
metadata:
labels:
app: fluent-bit
spec:
containers:
- name: fluent-bit
image: "fluent/fluent-bit:1.7-debug"
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "200Mi"
cpu: "500m"
ports:
- name: matrices
containerPort: 2020
protocol: TCP
volumeMounts:
- name: log-volume
mountPath: /var/log/
- name: config-volume
mountPath: /fluent-bit/etc/
securityContext:
supplementalGroups: [100003]
privileged: false
volumes:
- name: log-volume
persistentVolumeClaim:
claimName: data-3
readOnly: true
- name: config-volume
configMap:
name: flb-sidecar
以下是fluentbit配置-
data:
# Configuration files: server, input, filters and output
# ======================================================
fluent-bit.conf: |
[SERVICE]
Flush 5
Log_Level info
Daemon off
Parsers_File parsers.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2020
[INPUT]
Name tail
Tag demo.wen.api
Parser json
Path /var/log/log-*.json
Mem_Buf_Limit 10MB
Skip_Long_Lines On
Refresh_Interval 10
[OUTPUT]
Name stdout
Match *
parsers.conf: |
[PARSER]
Name json
Format json
Time_Key time
Time_Format %d/%b/%Y:%H:%M:%S %z
[PARSER]
Name docker
Format json
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
Time_Keep On
[PARSER]
Name syslog
Format regex
Regex ^<(?<pri>[0-9]+)>(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_/.-]*)(?:[(?<pid>[0-9]+)])?(?:[^:]*:)? *(?<message>.*)$
Time_Key time
Time_Format %b %d %H:%M:%S
推荐答案
您是否在连续写入该文件?在尾部部分未使用参数‘READ_FROM_HEAD’,这意味着流畅位将只跟在最新写入的数据之后。
这篇关于FluentBit不从共享PVC读取日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!