【问题标题】:Linux filebeat input collector for GraylogGraylog 的 Linux filebeat 输入收集器
【发布时间】:2020-10-20 21:40:07
【问题描述】:

我正在尝试为 Liunx 配置 Graylog 收集器 [filebeat]。我遇到问题的部分是路径:

我要从中收集日志的路径中包含许多日志文件。我只想收集格式为(示例)20201020.catalina.out的文件

我从命令行运行它,它可以在服务器上运行:

vi /var/log/oscar/`(date +"%Y%m%d.catalina.out")`

调出带有今天日期的文件。

我的 filebeat 配置示例:

> # Needed for Graylog fields_under_root: true fields.collector_node_id: ${sidecar.nodeName} fields.gl2_source_collector: ${sidecar.nodeId}
> 
> filebeat.inputs:
> - input_type: log
> 
>   paths:
>     
>     - /var/log/oscar/error-ssl.log
>     - /var/log/oscar/access-ssl.log
>     - /var/log/oscar/`(date +"%Y%m%d.catalina.out")`

当收集器运行时,它只捕获 error-ssl.log 和 access-ssl.log [logs]

【问题讨论】:

    标签: filebeat graylog2 graylog graylog3


    【解决方案1】:

    Filebeat 的 documentation 说“Go Glob 支持的所有模式也都支持这里。”

    Go Glob 的 documentation 说“模式的语法与 Match 中的相同”。

    最后,Match 的documentation 显示了支持的模式:

    The pattern syntax is:
    
    pattern:
        { term }
    term:
        '*'         matches any sequence of non-Separator characters
        '?'         matches any single non-Separator character
        '[' [ '^' ] { character-range } ']'
                    character class (must be non-empty)
        c           matches character c (c != '*', '?', '\\', '[')
        '\\' c      matches character c
    
    character-range:
        c           matches character c (c != '\\', '-', ']')
        '\\' c      matches character c
        lo '-' hi   matches character c for lo <= c <= hi
    

    因此,您必须处理这种模式。这样的事情应该可以工作:

         - /var/log/oscar/*.catalina.out
    

    【讨论】:

    • 是的,没错,但它也会读取该目录中的所有其他文件。我无法从该目录中删除带有日期时间戳的存档 .catalina 文件。我想忽略这些文件,只读取带有当前日期时间戳的 catalina.out 文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    相关资源
    最近更新 更多