【问题标题】:FluentBit - Is there a way to Truncate the Logs if they are too long?FluentBit - 如果日志太长,有没有办法截断日志?
【发布时间】:2021-07-01 14:00:26
【问题描述】:

FluentBit - 如果日志超过 1500 个字符,有没有办法截断日志???

不希望像整个堆栈一样被打印出来......

这个有配置吗???

【问题讨论】:

    标签: fluent-bit


    【解决方案1】:

    您可以通过捕获组和范围来限制 regex 解析器中要获取的字符数。

    例子:

    如果你有这行日志

    2021-07-25T13:39:00 INFO - Method foo() called with parameter "bar"

    你可以用

    完成截断
    [PARSER]
        Name   log_parser
        Format regex
        Regex  ^(?<time>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\s+(?<level>\w+)\s+-\s+(?<message>.{0,20}).*$
    

    这样,最多可以捕获 20 个字符,因此 message 将是:

    Method foo() called

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-24
      • 1970-01-01
      • 2021-12-27
      • 2018-06-02
      • 2020-04-10
      相关资源
      最近更新 更多