I’m noticed that Haproxy emits same message twice, with prefix like [WARNING] 237/195948 (6) :
and without it. I noticed this behavior while trying to run Haproxy in Docker, but with regular syslog setup situation exactly the same.
# docker run -it --rm --name haproxy -v /root/haproxy:/etc/haproxy -p 9101:9101/tcp -p 5432:5432/tcp haproxy:2.0 -f /etc/haproxy/haproxy.cfg
Proxy stats_prometheus started.
Proxy master started.
Proxy replicas started.
[NOTICE] 237/211032 (1) : New worker #1 (7) forked
[WARNING] 237/211032 (7) : Server master/dev-db-02 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 1ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server master/dev-db-02 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 1ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 237/211033 (7) : Server master/dev-db-03 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 2ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server master/dev-db-03 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 2ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 237/211033 (7) : Server replicas/dev-db-01 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 5ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server replicas/dev-db-01 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 5ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Connect from 172.17.0.1:45992 to 172.17.0.2:5432 (master/TCP)
Connect from 172.17.0.1:46014 to 172.17.0.2:5432 (master/TCP)
It looks like prefixed messages are emitted by master process (pid 1 in container) and non prefixed ones by worker process (pid 7).
Configuration.
global
log stdout format raw local0
maxconn 100
stats timeout 30s
pidfile /run/haproxy.pid
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
option dontlognull
default-server init-addr last,libc,none
resolvers localdns
parse-resolv-conf
listen stats_prometheus
bind *:9101
mode http
option http-use-htx
http-request use-service prometheus-exporter if { path /metrics }
stats enable
stats uri /stats
listen master
bind *:5432
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server dev-db-01 dev-db-01.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
server dev-db-02 dev-db-02.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
server dev-db-03 dev-db-03.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
listen replicas
bind *:5433
option httpchk OPTIONS /replica
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server dev-db-01 dev-db-01.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
server dev-db-02 dev-db-02.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
server dev-db-03 dev-db-03.domain.tld:5432 maxconn 120 check resolvers localdns port 8008
If log
line completely omitted from global
section I still get logs like
# docker run -it --rm --name haproxy -v /root/haproxy:/etc/haproxy -p 9101:9101/tcp haproxy:2.0 -f /etc/haproxy/haproxy.cfg
[NOTICE] 237/204228 (1) : New worker #1 (6) forked
[WARNING] 237/204229 (6) : Server master/dev-db-02 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 1ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 237/204229 (6) : Server master/dev-db-03 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 2ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[WARNING] 237/204230 (6) : Server replicas/dev-db-01 is DOWN, reason: Layer7 wrong status, code: 503, info: "HTTP status check returned code <3C>503<3E>", check duration: 5ms. 2 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
^C[WARNING] 237/205847 (1) : Exiting Master process...
[ALERT] 237/205847 (1) : Current worker #1 (6) exited with code 130 (Interrupt)
[WARNING] 237/205847 (1) : All workers exited. Exiting... (130)
But no connections like
Connect from 172.17.0.1:45992 to 172.17.0.2:5432 (master/TCP)
Connect from 172.17.0.1:46014 to 172.17.0.2:5432 (master/TCP)
are logged.
Question - it is possible to get rid of duplicates while still preserving all other log messages? I.e. it’s possible to suppress messages like
[WARNING] 237/204229 (6) : Server master/dev-db-02 is DOWN...
from master process while still preserving messages like
[NOTICE] 237/204228 (1) : New worker #1 (6) forked
and leaving worker messages
Server master/dev-db-02 is DOWN...
intact.
1 post - 1 participant
Read full topic