【发布时间】:2017-04-22 10:21:02
【问题描述】:
我对 kubernetes 非常陌生,并且在 GCE 中运行了带有 redis 和 mongodb 的测试应用程序。我想用 fluentd 获取我的日志文件并将它们发送到 logz:
我使用以下 fluentd 配置文件。我在本地机器上测试了一个类似的版本。
<source>
@type tail
path /var/log/containers/squidex*.log
pos_file /var/log/squidex.log.pos
tag squidex.logs
format json
</source>
<match squidex.logs>
@type copy
<store>
@type logzio_buffered
endpoint_url https://listener.logz.io:8071?token=...
output_include_time true
output_include_tags true
buffer_type file
buffer_path /fluentd/log/squidex.log.buffer
flush_interval 10s
buffer_chunk_limit 1m
</store>
<store>
@type stdout
</store>
</match>
我的 kubernetes 配置是:
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: fluentd-logging
labels:
app: fluentd-logging
spec:
template:
metadata:
labels:
app: fluentd-logging
spec:
containers:
- name: fluentd
image: gcr.io/squidex-157415/squidex-fluentd:latest
resources:
limits:
memory: 200Mi
requests:
cpu: 40m
volumeMounts:
- name: varlog
mountPath: /var/log
terminationGracePeriodSeconds: 30
volumes:
- name: varlog
hostPath:
path: /var/log
几乎一切正常,但是当我运行 fluentd pod 时,我在这些 pod 的日志输出中看到以下条目:
2017-04-22T09:49:22.286740784Z 2017-04-22 09:49:22 +0000 [warn]:
/var/log/containers/squidex-282724611-3nhtw_default_squidex-ed7c437e677d3438c137cdc80110d106339999a6ba8e495a5752fe6d5da9e70d.log unreadable.
It is excluded and would be examined next time
如何获得这些日志文件的权限?
【问题讨论】:
-
我认为您的问题是 /var/log/containers 并没有真正保存日志文件,而是链接到它们。应该链接到持有容器的FS。所以你可能应该同时安装两个
标签: docker kubernetes fluentd