我有一个PersistentVolumeClaims(聚氯乙烯)与ReadWriteMany (RWX)访问模式。这种聚氯乙烯是由两个豆荚。在第二个pod中,我让FluentBit读取应用程序pod在共享PVC中存储的日志。
问题是FluentBit识别这些文件。FluentBit打印到它找到一个新文件的日志。但是它不会读取新文件的内容以及日志如何插入到该文件中。。
我正在使用OpenShift 3.11,如果这有什么区别的话。如何在吊舱之间共享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
首先,Application声称这是用来存储应用程序日志的。
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
第二- FluentBit荚声称相同的聚氯乙烯在readOnly模式.
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
以下是流畅位的配置-
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
发布于 2021-08-25 07:05:31
你一直在写文件吗?在尾部部分,参数‘read_from_head’不被使用,这意味着Fluent位将只跟随最新写入的数据。
发布于 2022-09-30 18:37:39
我也有过同样的问题。通过关闭Inotify_Watcher
设置,我能够让它工作起来。
[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
Inotify_Watcher false
https://stackoverflow.com/questions/68712337
复制相似问题