HAProxy community

How can I see server (backend) ip-address


#1

Hi,
I’m looking for way to see server ip-address that HAPROXY learned during start process. I didn’t managed to find easy method to do it. May be someone faced such issue?

Ex:
server SRV1 serv.example.loc check …

How to see SRV1 ip-addr
Thanks!


#2

I had similar use case, to find the backend server IP. the way i solved it by custom logformat. By default haproxy logs clientIP & client port, so instead i used this, taken from https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#8.2.4

At the moment, the default HTTP format is defined this way :

log-format "%si:%sp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC \
            %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"

change is %si:%sp instead of %ci:%cp. Even though my backend mode was http with si, i was able to get the serverIP that served the request. Hope this helps.


#3

ykiran_k, thanks for reply. Currently I use similar solution. My customised log is:

log-format "%ci:%cp --> %fi:%fp %b/%s %bi:%bp --> %si:%sp %Tw/%Tc/%Tt in:%U/out:%B sess_start:%t %ts %ac/%fc/%bc/%sc/%rc %sq/%bq"

HAPROXY gives flexible log customisation tools, but I meant how to see servers’ ip-addresses on stats page or with “show stats”. Is it possible?


#4

Use show servers state on the admin socket.