首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FluentD无法解析日志文件内容

FluentD无法解析日志文件内容
EN

Stack Overflow用户
提问于 2021-08-31 05:54:05
回答 1查看 361关注 0票数 0

我正在尝试使用FluentD收集日志,但我得到了以下错误;

代码语言:javascript
运行
复制
2021-08-31 05:37:03 +0000 [warn]: #0 [tail_container_logs] pattern not match: "2021-08-31T05:37:03.133785104Z stderr F I0831 05:37:03.130864       1 main.go:227] handling current node"
2021-08-31 05:37:06 +0000 [warn]: #0 [tail_container_logs] pattern not match: "2021-08-31T05:37:05.474234466Z stdout F Hello world"
2021-08-31 05:37:08 +0000 [warn]: #0 [tail_container_logs] pattern not match: "2021-08-31T05:37:07.195447969Z stderr F 2021-08-31 05:37:07.195301 I | etcdserver/api/etcdhttp: /health OK (status code 200)"

我的fluent.conf文件如下;

代码语言:javascript
运行
复制
<source>
  @type tail
  @id tail_container_logs
  path /var/log/containers/*.log
  pos_file /var/fluent/log/containers.log.pos
  time_format %Y-%m-%dT%H:%M:%S.%NZ
  tag kubernetes.*
  exclude_path "/var/log/containers/my-fluent*.log"
  read_from_head true
  <parse>
    @type json
    time_format %Y-%m-%dT%H:%M:%S.%NZ
  </parse>
</source>

<filter kubernetes.**>
  @type kubernetes_metadata
</filter>

<match kubernetes.**>
  @type file
  @id   output1
  path         /var/fluent/log/log/data.*.log
  append       true
</match>

当我检查运行kind kubernetes集群的主机(而不是kubernetes节点)上的Docker日志记录驱动程序配置时,它显示json-file为日志记录驱动程序。

但是,我无法在CRI的节点中找到日志记录驱动程序配置。当我连接到节点并运行crictl info时,它显示了配置,但没有日志记录驱动程序。经过进一步的研究,我发现cri-o日志记录没有json支持。我怀疑唯一可用的选项是在FluentD配置中使用@type正则表达式。

关于如何在fluentD中解析cri-o日志,有什么建议吗?

提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2021-08-31 10:05:22

我能够使用在fluent-bit主题中找到的正则表达式来解析cri-o日志。以下是部件的fluentD配置。

代码语言:javascript
运行
复制
<source>
  @type tail
  @id tail_container_logs
  path /var/log/containers/*.log
  pos_file /var/fluent/log/containers.log.pos
  time_format %Y-%m-%dT%H:%M:%S.%NZ
  tag kubernetes.*
  exclude_path "/var/log/containers/my-fluent*.log"
  #format json_in_json
  read_from_head true
  <parse>
    @type regexp
    expression /^(?<time>.+)\b(?<stream>stdout|stderr)\b(?<log>.*)$/
    time_key time
    time_format %Y-%m-%dT%H:%M:%S.%NZ
  </parse>
</source>

目前还没有用于FluentD的cri-o解析器。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68993514

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档