haproxy with nbproc>1

489 views
Skip to first unread message

djw...@gmail.com

unread,
Jul 3, 2015, 7:17:43 PM7/3/15
to prometheus...@googlegroups.com
Hi,
I've tried recently promotheus and loved it. I specially test the haproxy exporter, but my config use 4 procs, and due to haproxy nature, metrics fetched using url are random (metrics are only from process which reply to the http request)

So i tried to fix the issue using stats from sockets and manage to patch haproxy_export.go by myself (never play with Go before)
And I get It!

First step use one socket per proc
in my haproxy.conf :
global
nbproc 4
stats socket /var/run/haproxy.1 mode 600 level admin process 1
stats socket /var/run/haproxy.2 mode 600 level admin process 2
stats socket /var/run/haproxy.3 mode 600 level admin process 3
stats socket /var/run/haproxy.4 mode 600 level admin process 4

if you do
echo "show stat" |socat /var/run/haproxy.1 stdio
you get stats for proc 1 only, exactly the same as http://localhost/haproxy;csv


in my fix, i add a flag "socket" which can be set more than once
./haproxy_exporter2 -socket /var/run/haproxy.1 -socket /var/run/haproxy.2 -socket /var/run/haproxy.3 -socket /var/run/haproxy.4

the metrics are labeled with the pid (process ID) which give something like this
haproxy_backend_bytes_in_total{backend="prod",pid="1"} 34624
haproxy_backend_bytes_in_total{backend="prod",pid="2"} 116653
haproxy_backend_bytes_in_total{backend="prod",pid="3"} 105333
haproxy_backend_bytes_in_total{backend="prod",pid="4"} 37046

I'm new in Go, so my patch would be review for sure, but seems to work
If you are interested i can share it.

David.

lesgp...@gmail.com

unread,
Jul 19, 2015, 2:23:41 PM7/19/15
to prometheus...@googlegroups.com, djw...@gmail.com, lester...@echostar.com
David,

I am having the same issue. Could I get a copy of your patch / fix along with any instructions you deem pertinent? Possibly a copy of your conf as well.

Thanks a ton,
Lester...@echostar.com

Reply all
Reply to author
Forward
0 new messages