glogcenter/fluentd/fluent.conf
2024-09-09 09:13:36 +08:00

41 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<system>
log_level info
</system>
<filter *>
@type record_transformer
enable_ruby
<record>
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}
system ${"glogcenter"}
</record>
remove_keys container_id,container_name,source,log
</filter>
<match *>
@type copy
<store>
@type http
headers {"X-GLC-AUTH":"glogcenter"}
endpoint http://172.1.2.3:8080/glc/v1/log/addBatch
open_timeout 2
http_method post
json_array true
<format>
@type json
</format>
<buffer>
flush_interval 1s
</buffer>
</store>
</match>