Score:0

Haproxy Stats page not working with TCP mode

bj flag

Haproxy experts,

I'm unable to get haproxy stats page to work with TCP mode for the backends.

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

defaults
    mode                    tcp
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
    stats enable
    stats hide-version
    stats refresh 30s
    stats show-node
    stats auth admin:xxxxxxxxxxxxxxxxx
    stats uri /haproxy?stats

frontend main
    listen stats
    bind *:5000
    mode tcp
    default_backend             app

backend app
    balance     roundrobin
#backends
    server   server1  xxx.xxx.xxx.xxx:10222 check
    server   server2  xxx.xxx.xxx.xxx:34013 check
in flag
Please don't post screenshots of text that you could copy&paste. Just copy&paste it into the question, you are just making it harder for people to extract information from it.
in flag
You can use the text formatting tools. Or just paste it as it is, someone will format it properly for you.
Nikita Kipriyanov avatar
za flag
Whoever wants to get help makes it easy for a potential helper to give a help. And it is very inconvenient to be required to go via links to pictures to read text from them, the text which should have been embedded into the question as text. So personally I won't bother looking at your pictures, and base all my help on what I see in the question directly. // That said, haproxy **stats require HTTP mode**. So yes, it is not working in TCP, this is how it is intended. If you don't have HTTP listeners you need to create one just for the stats. It will list TCP things too on the stats page.
Score:0
za flag

HAproxy requires HTTP mode listener for the stats page, period. If you want stats, you need to have or create one.

This could be implemented with simple listen section without any actual backends, if you don't have any HTTP backends or if you want stats page to not to be bound to any existing HTTP listeners.

Remove all stats-related lines from defaults, and create an individual listen section just for the stats, where you put all those lines:

listen stats
    mode http
    bind *:8080
    stats enable
    stats hide-version
    stats refresh 30s
    stats show-node
    stats auth admin:xxxxxxxxxxxxxxxxx
    stats uri /haproxy?stats

Also remove your listen stats line just after frontend main. What it does currently is terminating "frontend" section main (which happens to be empty and only has defaults), creating new "listen" section stats and applying the following few lines to it. I am sure this is not what you want.

Lamboo avatar
bj flag
You're the best man. :) Thanks. It worked like charm. Kudus
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.