gpt4 book ai didi

elasticsearch - Filebeat收获旋转文件

转载 作者:行者123 更新时间:2023-12-02 23:47:01 25 4
gpt4 key购买 nike

问题描述:

我有较大的 / var / log / messages 文件,该文件已旋转。
文件列表如下所示:

ls -l /var/log/messages*
-rw-------. 1 root 928873050 Mar 5 10:37 /var/log/messages
-rw-------. 1 root 889843643 Mar 5 07:49 /var/log/messages.1
-rw-------. 1 root 890148183 Mar 5 07:50 /var/log/messages.2
-rw-------. 1 root 587333632 Mar 5 07:51 /var/log/messages.3

我的文件拍配置片段:
filebeat.prospectors:
- input_type: log
paths:
- /var/log/messages
- /var/lib/ntp/drift
- /var/log/syslog
- /var/log/secure
tail_files: True

每次重新启动文件信号时,使用多个 / var / log / messages * 文件(如上图所示),它开始收集和摄取旧的日志文件。
当我只有一个 / var / log / messages 文件时,不会观察到此问题。

最佳答案

在Linux系统上,Filebeat不会按文件名跟踪文件,而是使用重命名时不会更改的inode号来跟踪文件。这来自Filebeat documentation

The harvester is responsible for opening and closing the file, which means that the file descriptor remains open while the harvester is running. If a file is removed or renamed while it’s being harvested, Filebeat continues to read the file. This has the side effect that the space on your disk is reserved until the harvester closes. By default, Filebeat keeps the file open until close_inactive is reached.



这意味着这就是您的情况
  • 读取当前消息文件(inode#1),并在注册表中跟踪其inode编号。
  • Filebeat停止,但是消息文件旋转为messages.1(inode#1)和新消息(inode#2)文件已创建。
  • Filebeat重新启动时,它将开始读取
  • messages.1(inode#1)文件,从
  • 停止
  • 消息(inode#2),因为它与您配置的路径(/ var / log / messages)匹配

  • 如果您的计划是收获所有消息文件,甚至是轮换的,那么最好将路径配置为

    /var/log/messages*

    关于elasticsearch - Filebeat收获旋转文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60548323/

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