Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine HAProxy stats?

Tags:

haproxy

I have two instances of HAProxy. Both instances have stats enabled and are working fine.

I am trying to combine the stats from both instances into one so that I can use a single HAProxy to view the front/backends stats. I've tried to have the stats listener on the same port for both haproxy instances but this isn't working. I've tried using the sockets interface but this only reports on one of the interfaces as well.

Any ideas?

My one haproxy config file looks like this:

global
    daemon
    maxconn 256
    log 127.0.0.1 local0 debug
    log-tag haproxy
    stats socket /tmp/haproxy

defaults
    log global
    mode http
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http-in
    bind *:8000
    default_backend servers
    log global
    option httplog clf

backend servers
    balance roundrobin
    server ws8001 localhost:8001
    server ws8002 localhost:8002
    log global

listen admin
    bind *:7000
    stats enable
    stats uri /

The other haproxy config is the same except the front/backend server IPs are different.

like image 721
davetropeano Avatar asked Jun 24 '14 19:06

davetropeano


2 Answers

While perhaps not an exact answer to this specific question, I've seen this kind of question enough that I think it deserves to be answered.

When running with nbproc greater than 1, the Stack Exchange guys have a unique solution. They have a listen section that receives SSL traffic and then uses send-proxy to 127.0.0.1:80. They then have a frontend that binds to 127.0.0.1:80 like this: bind 127.0.0.1:80 accept-proxy. Inside of that frontend they then bind that frontend, e.g. bind-process 1 and in the globals section the do the following:

global
    stats socket /var/run/haproxy-t1.stat level admin
    stats bind-process 1

The advantage of this is that they get multiple cores for SSL offloading and then a single core dedicated to load balancing traffic. All traffic ultimately flows through this frontend and therefore they can accurately measure stats from that frontend.

like image 111
Jonathan Oliver Avatar answered Nov 12 '22 17:11

Jonathan Oliver


This can't work. Haproxy keeps stats separated in each process. It has no capabilities to combine stats of multiple processes.

That said, you are of course free to use external monitoring tools like (munin, graphite or even nagios) which can aggregate the CSV data from multiple stats sockets and display them in unified graphs. These tools are however out-of-scope of core haproxy.

like image 43
Holger Just Avatar answered Nov 12 '22 17:11

Holger Just