Due to a bug in the parse_log processor, the version currently used on cp hosts (4.15.0) we can't really use the new rfc5424 syslog format for defining log from HAProxy:
Example of (minimal) HAProxy log configuration
log 127.0.0.1:1221 format rfc5424 local0 info
log-format "%rt %Tr %Tw %Tc %ST {%[capture.req.hdr(0)]} {%[capture.res.hdr(0)]} %ts"
log-format-sd [benthoslog\ haproxy_pid=\"%pid\"\ other=\"%T\"]Example of a (minimal) Benthos configuration:
http:
enabled: true
address: "0.0.0.0:5123"
debug_endpoints: true
input:
label: "syslog"
socket_server:
network: udp
address: 127.0.0.1:1221
codec: lines
tls:
cert_file: ""
key_file: ""
self_signed: false
pipeline:
threads: -1
processors:
- log:
message: "PRE_LOG ${! content() }"
- label: "syslog_format"
parse_log:
format: "syslog_rfc5424"
codec: "json"
- label: main_mapping
mapping: |
root = this.structureddata.benthoslog
logger:
level: DEBUG
format: logfmt
output:
stdout:
codec: linesSending a simple CURL to HAProxy here's the output (with also the debug log that shows the "raw" log before being parsed from the parse_log processor):
- Current production version (4.15.0):
INFO Receiving udp socket messages from address: 127.0.0.1:1221 @service=benthos label=syslog path=root.input
INFO Launching a benthos instance, use CTRL+C to close @service=benthos
INFO PRE_LOG <134>1 2024-05-27T20:15:21.448152+00:00 - haproxy 1649554 - [benthoslog haproxy_pid="1649554" other="27/May/2024:20:15:19 +0000"] 105 -1 -1 -1 200 {mydomain.it} {-} LR @service=benthos label="" path=root.pipeline.processors.0
null- Latest version (4.27.0)
INFO Receiving udp socket messages from address: 127.0.0.1:1221 @service=benthos label=syslog path=root.input
INFO Input type socket_server is now active @service=benthos label=syslog path=root.input
INFO Launching a benthos instance, use CTRL+C to close @service=benthos
INFO Output type stdout is now active @service=benthos label="" path=root.output
INFO PRE_LOG <134>1 2024-05-27T20:16:16.754217+00:00 - haproxy 1649554 - [benthoslog haproxy_pid="1649554" other="27/May/2024:20:16:16 +0000"] 119 -1 -1 -1 200 {mydomain.it} {-} LR @service=benthos label="" path=root.pipeline.processors.0
{"haproxy_pid":"1649554","other":"27/May/2024:20:16:16 +0000"}In the latest version the message is correctly interpreted as json object and fields parsed.
The bug should've been fixed in version 4.23.0 (commit) but I suggest to upgrade (at least on cache hosts) to latest version as performances has been improved since.