是否可以使用流利位记录的时间戳?

问题描述

我正在尝试创建一个流利的位配置,该配置使用记录的时间戳和使用过滤器的自定义键。像这样:

[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

这可能吗?

解决方法

我从流利的松弛通道中得到了答案。

似乎可以使用lua filters这样。具体而言,该示例似乎是相关的:https://github.com/fluent/fluent-bit/blob/master/scripts/append_tag.lua

,

我有同样的问题。 根据@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,new_record
end

这是 td-agent-bit 配置。

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

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