rancher: Load balancer logs are empty - error during parsing file /etc/haproxy/rsyslogd.conf
The HAProxy logs in /var/log/haproxy/ are empty in the load balancer container. From the error messages in /var/log/messages it looks like those parenthesis on the if-then lines in rsyslogd.conf should be curly braces. Please see the example at the end of this page: RSYSLOG if then
Also see recent comments in issue 2414.
Rancher Versions: Server: v1.4.0-rc5 (also in v1.3.3) healthcheck: v0.2.3 ipsec: holder network-services: ? scheduler: v0.6.1 kubernetes (if applicable): n/a
Docker Version: 1.13.0
OS and where are the hosts located? (cloud, bare metal, etc): Ubuntu 16.04, bare metal
Setup Details: (single node rancher vs. HA rancher, internal DB vs. external DB) single node rancher, internal DB
Environment Type: (Cattle/Kubernetes/Swarm/Mesos) Cattle
Steps to Reproduce:
- fresh install of Rancher server
- add a host
- create a new stack in the default environment
- add a service (rawmind/web-test for example)
- add a load balancer and configure a port with its target pointing to the service
- make some requests to the load balancer’s port
Results:
Navigate to load balancer container in rancher ui and select Execute Shell
haproxy logs:
root@8d303d0449d6:/# ls -l /var/log/haproxy/
total 0
-rw-r--r-- 1 root root 0 Jan 24 22:27 errors
-rw-r--r-- 1 root root 0 Jan 24 22:27 events
-rw-r--r-- 1 root root 0 Jan 24 22:27 traffic
root@8d303d0449d6:/#
/var/log/messages output:
root@8d303d0449d6:/# tail -n 50 /var/log/messages
Jan 29 23:13:04 8d303d0449d6 rsyslogd: [origin software="rsyslogd" swVersion="8.
16.0" x-pid="28" x-info="http://www.rsyslog.com"] start
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 7: invalid character '(' - is there an invali
d escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 9: invalid character ')' - is there an invali
d escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 10: invalid character '(' - is there an inval
id escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 12: invalid character ')' - is there an inval
id escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 14: invalid character '(' - is there an inval
id escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
Jan 29 23:13:04 8d303d0449d6 rsyslogd-2207:error during parsing file /etc/haprox
y/rsyslogd.conf, on or before line 16: invalid character ')' - is there an inval
id escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
haproxy’s rsyslogd configuration:
root@8d303d0449d6:/# cat /etc/haproxy/rsyslogd.conf
$ModLoad imudp.so
$UDPServerRun 8514
$template CustomFormat,"%timegenerated% %HOSTNAME% %syslogtag%%msg%\n"
$ActionFileDefaultTemplate CustomFormat
/* info */
if $programname contains 'haproxy' and $syslogseverity == 6 then (
action(type="omfile" file="/var/log/haproxy/traffic")
)
if $programname contains 'haproxy' and $syslogseverity-text == 'err' then (
action(type="omfile" file="/var/log/haproxy/errors")
)
/* notice */
if $programname contains 'haproxy' and $syslogseverity <= 5 then (
action(type="omfile" file="/var/log/haproxy/events")
)
*.* /var/log/messages
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 22 (3 by maintainers)
@jmoscato, I was able to resolve it in my setup by adding this code to rancher-compose.yml
log 127.0.0.1:8514 local0
- 8514 is the rsyslog listening port in Rancher’s HAProxy container. I think this should be added to the documentation.Hi @kinarashah Thanks for your feedback. I tried to send some requests through the load balancer (a few tens of them) but get very little information from stderr and stdout:
All these messages are reporting is the IP of the machine where the requests are coming from (10.134.45.21) and the IP of the load balancer container (10.42.75.129):
But there is no information about connection to the backend containers and status of the requests going through
Tested with rancher/server: Build from V1.6 branch Lb image - rancher/lb-service-haproxy:v0.7.6
Scenario 1: Create a service Add a load balancer and configure a port with its target pointing to this service (without enabling logging). Make some requests to the load balancer’s port No logs are generated for haproxy traffic - /var/log/haproxy/events|errors|traffic are empty. /var/log/messages does not show any error messages relating to parsing file /etc/haproxy/rsyslogd.conf
Scenario 2: Create a service Add a load balancer and configure a port with its target pointing to this service with following custom config for enabling logs:
Make some requests to the load balancer’s port
Haproxy events and traffic related messages get logged in both - /var/log/haproxy/traffic and /var/log/haproxy/events . https://github.com/rancher/rancher/issues/9369 - logged for redundant logging.
Awesome. Is this documented somewhere?
Solved this by explicitly setting the log format for the frontends in HAProxy with option httplog
Entries in the log file now look like this:
5/25/2018 12:20:46 PMMay 25 10:20:46 localhost haproxy[351]: 10.134.45.21:15810 [25/May/2018:10:20:35.465] 443~ 443_application_cluster/123436406cec0b9217672c7306ba9b6f2 9496/0/1/1827/11327 200 1022 - - ---- 6/6/0/1/0 0/0 "GET /application/test? HTTP/1.1"
With HTTP status, backend name, server name, ecc…
@randomorder sometime after this, https://github.com/rancher/rancher/issues/9616, logs from those files were redirected to UI. are you able to see events and traffic getting logged in Standard Out and Errors in Standard Error under “View Logs”?
Any updates on this? I am seeing
Apr 7 19:05:13 dfde93741290 rsyslogd-2207:error during parsing file /etc/haproxy/rsyslogd.conf, on or before line 16: invalid character ')' - is there an invalid escape sequence somewhere? [v8.16.0 try http://www.rsyslog.com/e/2207 ]
in myrancher/lb-service-haproxy:v0.5.9
containers. All of my logs are empty in/var/log/haproxy/*
I also have the same config as others above, such as @VAdamec