Skip to content

Commit 70695e2

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents a5b9950 + 1e6c6ea commit 70695e2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

services/logging/fluentd/fluent.conf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
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
@@ -38,10 +40,22 @@
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
@@ -54,6 +68,12 @@
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

0 commit comments

Comments
 (0)