【问题标题】:Config filebeat only to read last 5 day of log files配置 filebeat 仅读取最近 5 天的日志文件
【发布时间】:2019-10-24 19:46:29
【问题描述】:

我在“logs”文件夹中有几个以下目录格式的日志文件

2019-10-22
2019-10-21
2019-10-20
2019-10-19

每个文件夹上方都有Error.log 文件。我想从filebeat读取2019-10-20到上面的那些Error.log文件并推送到弹性搜索。如何使用 filebeat.yml 来做到这一点

这是我的 filebaet.yml 部分

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - d:\sites\*\logs\*\Error.log

  fields:
    level: error
    application: cms

  ### Multiline options
  multiline.pattern: '^([0-9]{4}-[0-9]{2}-[0-9]{2})'
  multiline.negate: true
  multiline.match: after
  pipeline: logpipeline

【问题讨论】:

标签: elasticsearch logging filebeat


【解决方案1】:

我认为这不是一个完美的答案。但是对于这种情况,您可以在 filebeat 中使用功能exclude_lines。在您的 filebeat.yml 文件中进行如下配置并尝试。

 filebeat.inputs:

- type: log
  enabled: true
  paths:
     - /var/log/*.log

  exclude_lines: ['^2019-10-1']

这将排除以“2019-10-1”开头的行

【讨论】:

    【解决方案2】:

    终于找到了。文件节拍配置允许按时间忽略文件。您可以将其用作分钟(24 秒)、24 小时(24 小时)、24 天(24 天)

    - type: log
      enabled: true
      paths:
        - d:\annywhere\logs\*\Error.log
    
      ignore_older: 24h
    

    【讨论】:

      猜你喜欢
      • 2016-02-18
      • 2022-08-14
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      • 2016-06-09
      • 1970-01-01
      • 2015-10-18
      • 2022-01-22
      相关资源
      最近更新 更多