File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 3030 @type forward
3131 port 24224
3232 bind 0.0.0.0
33+ # Add source hostname to records
34+ source_hostname_key source_hostname
3335</source>
3436
3537# Add additional metadata
3840 <record>
3941 hostname "#{Socket.gethostname}"
4042 fluentd_hostname "#{ENV['FLUENTD_HOSTNAME']}"
41- tag ${tag}
4243 </record>
4344</filter>
4445
46+ # Clean container names and set proper host field
47+ <filter docker.**>
48+ @type record_transformer
49+ enable_ruby true
50+ <record>
51+ # cleanup container names by removing leading slashes
52+ container_name ${record["container_name"] ? record["container_name"].sub(/^\//, '') : record["container_name"]}
53+ # Use source hostname from forward input as the host field for GELF
54+ host ${record["source_hostname"] || record["source"] || record["_hostname"] || "unknown"}
55+ </record>
56+ </filter>
57+
58+
4559# Output to both Graylog (GELF) and Loki
4660<match docker.**>
4761 @type copy
5468 protocol udp
5569 add_msec_time true
5670 flush_interval 5s
71+ # Use the host field from record for GELF host field
72+ use_record_host true
73+ # Map the correct fields for Graylog
74+ <format>
75+ @type json
76+ </format>
5777 <buffer>
5878 @type file
5979 path /fluentd/buffer/graylog
You can’t perform that action at this time.
0 commit comments