Using HAProxy, you can construct high-availability systems and HAProxy stats provide detailed statics. It can be used with popular servers like Apache, Tomcat, NGINX, and others. This post describes how to enable HAProxy statistics on your machine. After you have configured and installed HAProxy on your system, you may monitor its statistics to determine its current performance.
With HAProxy Stats, you can view information about the number of connections, data transfer, server status, and more. Because it is browser-based, you can use a web browser to get real-time information about your HAProxy implementation. In this article, we delineate how to enable HAProxy Stats on your system. Perform these procedures only if you’ve installed and configured HAProxy on your server.
Step 1 – Enable HAProxy Statics
You would need privileged account access to the HAProxy server. Open a terminal and edit the main HAProxy configuration file in text editor:
sudo vi /etc/haproxy/haproxy.cfg
Add the configuration that begins with the “stats” keyword.
listen stats 192.168.10.10:1936 mode http log global maxconn 10 clitimeout 100s srvtimeout 100s contimeout 100s timeout queue 100s stats enable stats hide-version stats refresh 30s stats show-node stats auth admin:password stats uri /haproxy?stats
The first line of the code specifies the IP address where HAProxy statistics are available. It is also listening on port 1936. When you use a web browser to request HAProxy statistics, you must provide a username and password. The last line specifies the URL where you can access HAProxy statistics. You are free to change it as you wish. The last bit of information is a username and password, which are admin and password, respectively.
HAProxy must be restarted to take effect after you save and exit the configuration file.
Step 2 – Access HAProxy Stats
You can access HAProxy stats using the following URL. Use your server ip address followed by
stats uri in above configuration. Use login details configured with
stats auth in configuration file.
URL: http://192.168.10.10:1936/haproxy?stats Login user: admin Login password: password
Step 3 – Change Login Details
If you want to change the login in HAProxy stats configuration, edit the main configuration and update the “stats auth” value as shown below:
stats auth username:password
Save the configuration file and restart the HAProxy service to apply changes.
Step 4 – Change HAProxy Stats URL
The HAProxy URL is fully customization. You can set any sub URL as the HAProxy statics URL. To change URL of HAProxy stats edit the configuration file and update the following value.
stats uri /haproxy?stats
stats uri /stats
Save the configuration file and restart HAProxy to update the service. Now you can access URL like http://192.168.10.10:1936/stats.
Haproxy stats configuration has been completed successfully.
One of the finest load balancers to construct high availability systems is HAProxy. With Apache, Tomcat, NGINX, and other popular servers, HAProxy can easily be configured. In this piece, we’ve learned how to activate HAProxy statistics on our system. After you’ve installed and configured HAProxy on your system, you may turn on its statistics to obtain real-time information about your load balancer.