fluentd:v1.17-1 配置示意

This commit is contained in:
gotoeasy 2024-09-09 09:13:36 +08:00
parent 0f3e3c42d5
commit 0932f9a3cb

View File

@ -11,8 +11,8 @@
@type record_transformer
enable_ruby
<record>
loglevel ${case record["log"] when /.*\[info\].*/i then "INFO" when /info /i then "INFO" when /.*\[warning\].*/i then "WARN" when /warn /i then "WARN" when /.*\[error\].*/i then "ERROR" when /error /i then "ERROR" else "DEBUG" end}
text ${"【这是收集的容器日志】"+record["log"].gsub("DEBUG ", "").gsub("INFO ", "").gsub("WARN ", "").gsub("ERROR ", "").gsub(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} /, "").gsub(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} /, "")}
loglevel ${case record["log"] when / info /i then "INFO" when / warn /i then "WARN" when / error /i then "ERROR" else "DEBUG" end}
text ${"【这是收集的容器日志】"+record["log"].gsub(/debug |info |warn |error /i, "").gsub(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} /, "")+"\n这是原日志\n"+record["log"]}
servername ${record["container_name"].gsub("/", "")}
serverip ${"127.0.0.1"}
date ${case record["log"] when /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} / then record["log"].match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3} /)[0] else time.strftime('%Y-%m-%d %H:%M:%S.%3N') end}