Skip to content

Commit 4d2e914

Browse files
sandereggmrnicegyu11
authored andcommitted
ensure graylog source is correct (ITISFoundation#1189)
1 parent a7a9af9 commit 4d2e914

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

services/logging/fluentd/fluent.conf

Lines changed: 12 additions & 2 deletions
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,16 +40,18 @@
3840
<record>
3941
hostname "#{Socket.gethostname}"
4042
fluentd_hostname "#{ENV['FLUENTD_HOSTNAME']}"
41-
tag ${tag}
4243
</record>
4344
</filter>
4445

45-
# Clean container names (Ruby needed) by removing leading slashes
46+
# Clean container names and set proper host field
4647
<filter docker.**>
4748
@type record_transformer
4849
enable_ruby true
4950
<record>
51+
# cleanup container names by removing leading slashes
5052
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"}
5155
</record>
5256
</filter>
5357

@@ -64,6 +68,12 @@
6468
protocol udp
6569
add_msec_time true
6670
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>
6777
<buffer>
6878
@type file
6979
path /fluentd/buffer/graylog

0 commit comments

Comments
 (0)