Match 仅适用于 *,我不明白为什么会发生这种情况。这是我的配置。
鲁阿
function process_record(tag, timestamp, record)
print("Input tag: ", tag)
print("Record: ", record["tag"])
local s3_log = {}
local cw_log = {}
for k, v in pairs(record) do
cw_log[k] = v
cw_log["tag"] = "cw"
s3_log[k] = v
s3_log["tag"] = "s3"
end
print("S3 tag: ", s3_log["tag"])
print("CW tag: ", cw_log["tag"])
print("S3 Log: ", s3_log["log"])
print("CW Log: ", cw_log["log"])
return 2, timestamp, {s3_log, cw_log}
end
配置
[SERVICE]
flush 1
daemon off
log_level debug
[FILTER]
Name lua
Match *
script /append_tag.lua
call process_record
[FILTER]
Name lua
Match $tag cw
script /print.lua
call process_record
[FILTER]
Name rewrite_tag
Match cw
Rule $tag .* cw true
Emitter_Name cw_emitted
[OUTPUT]
Name cloudwatch_logs
Match *cw*
# Match *
# Match_regex ^(cw)$
log_key log
region af-south-1
log_group_name /ecs/log
log_stream_prefix fluent-bit-
auto_create_group On
log_format json/emf
附加信息:
Fluent Bit 版本:AWS_FOR_FLUENT_BIT_VERSION 2.32.2.20240627
AWS Fargate 设置
使用 log_router 容器