【问题标题】:Is it possible to use a fluent-bit record's timestamp?是否可以使用流利位记录的时间戳?
【发布时间】:2020-09-03 17:24:12
【问题描述】:

我正在尝试创建一个流利的位配置,它使用记录的时间戳到使用过滤器的自定义键。比如:

[INPUT]
  Name tail
  Path /some/path
  ... 

[FILTER]
  Name record_modifier
  Match *
  Record fluenbit_orig_ts SOME_MAGIC_WAY_TO_GET_UNIXTIME

[OUTPUT]
  Name           stdout
  Match          *

我使用多个解析器的理由,每个都有自己的时间格式(Time_Format,因为它用于正则表达式解析器。即使我使用Time_Keep,它也无济于事,因为不同的服务指定不同的时间,使用不同的Time_Format)。我希望到达[OUTPUT} 的记录具有相同的键来描述时间戳。在此示例中,该键为 fluenbit_orig_ts

这可能吗?

【问题讨论】:

    标签: fluent-bit


    【解决方案1】:

    我也有同样的问题。 根据@BugoK,我已经解决了。

    这是 lua 脚本。

    function append_tag(tag, timestamp, record)
        new_record = record
        new_record["log_time"] = os.date("%Y-%m-%d %H:%M:%S")
        return 1, timestamp, new_record
    end
    

    这是 td-agent-bit 配置。

    [FILTER]                                                                                                 
    Name lua                                                                                             
    Match nginx.access                                                                                   
    script override_time.lua                                                                             
    call append_tag
    

    然后重启 td-agent-bit。有效~!

    【讨论】:

      【解决方案2】:

      我从 fluent-bit slack 频道得到了答案。

      使用lua filters 似乎可以做到这一点。具体来说,这个例子似乎是相关的:https://github.com/fluent/fluent-bit/blob/master/scripts/append_tag.lua

      【讨论】:

        猜你喜欢
        • 2022-12-08
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-30
        • 1970-01-01
        相关资源
        最近更新 更多