You are here
HAProxy Monitoring Opspack
HAProxy is an open-source tool offering high availability, load balancing, and proxying for TCP and HTTP-based applications. Well-suited for high traffic websites, HAProxy has become the industry standard open-source load balancer and is often shipped with most mainstream Linux distributions as well as commonly deployed by default in cloud platforms.
Its mode of operation makes integration into existing architectures quite simple and keeps security in mind, ensuring that valuable web servers with private information are not exposed.
What You Can Monitor
This Opspack allows you to monitor all the metrics you need to efficiently run a HAProxy Server, providing HAProxy monitoring service checks for connections, requests, responses and sessions, as well as the number of ingoing and outgoing bytes.
Host Template
The following Host Template is currently provided by this Opspack.
Host Template | Description |
---|---|
Application - Haproxy | Monitor an HAProxy Server |
Service Checks
Service Check Name | Description | Default Thresholds (Warning, Critical) | UOM |
---|---|---|---|
Haproxy - Bytes | Checks the bytes in and bytes out. | Bytes_In=1000000,2000000 Bytes_Out=1000000,2000000 |
B |
Haproxy - Connect Time | The time in ms for a session to connect. | Connect_Time=1000,2000 | ms |
Haproxy - Currrent Queue | The current number in the queue. | Current_Queue=200,300 | count |
Haproxy - Denied Connection | HAProxy 1.7 only The number of denied connections made to the system. |
Denied_Connection=10,15 | count |
Haproxy - Denied Requests | The number of denied requests made to the system. | Denied_Request=10,15 | count |
Haproxy - Denied Response | The number of denied responses made to the system. | Denied_Response=10,15 | count |
Haproxy - Denied Sessions | HAProxy 1.7 only The number of denied sessions made to the system. |
Denied_Response=10,15 | count |
Haproxy - Error Connections | The number of error connections. | Error_Connection=10,15 | count |
Haproxy - Error Requests | The number of error requests. | Error_Request=10,15 | count |
Haproxy - Error Response | The number of error responses. | Error_Response=10,15 | count |
Haproxy - Intercepted Requests | HAProxy 1.7 only The number of intercepted requests. |
Intercepted_Requests=900,1000 | count |
Haproxy - Queue Time | The time in ms of the queue session. | Queue_Time=1000,2000 | ms |
Haproxy - Request Rate | The number of requests per second. | Request_Rate=1000,2000 | count/s |
Haproxy - Request Time | The time in ms of the session request. | Request_Time=1000,2000 | ms |
Haproxy - Response Codes | The number of code responses of each type. | Code_4xx=300,450 Code_5xx=300,450 Code_Other=300,450 |
count |
Haproxy - Session Rate | The number of sessions per second. | Session_Rate=1000,2000 | count/s |
Haproxy - Sessions Used | The percentage of used sessions. | Sessions_Used=70,90 | % |
Haproxy - Status | Checks the status of the proxy. | N/A | N/A |
Haproxy - Warnings Redispatched | The number of redispatched warnings. | Warnings_Redispatched=10,15 | count |
Haproxy - Warnings Retried | The number of retried warnings. | Warnings_Retried=10,15 | count |
HAProxy Monitoring Prerequisites
HAProxy has been tested against versions 1.5, 1.6 and 1.7.
HAProxy Monitoring Setup
To configure HAProxy, you need to set up a statistics page on the server as follows.
Update the haproxy.cfg
Update /etc/haproxy/haproxy.cfg
with the lines below for each proxy.
listen stats
bind <Your haproxy IP>:<Port>
mode http
stats enable
stats hide-version
stats realm haproxy\ Statistics
stats uri /haproxy?stats
stats auth <Username>:<Password>
Restart HAProxy
sudo service haproxy restart
Test the stats are running correctly
Visit http://<Your haproxyIP>:<Port>/haproxy?stats
and view the statistics.
Usage Instructions
NOTE: If you are running HAProxy version 1.5 or 1.6 three service checks will need to be deactivated as the metrics are not available for those versions:
- Haproxy - Denied Connection
- Haproxy - Denied Sessions
- Haproxy - Intercepted Requests
Step 1: Add this Host Template
Add the Application - Haproxy Host Template to your Opsview host. If the resource you're monitoring has no hostname or public IP, then open the Advanced settings pane and change Host Check Command to Always assumed to be UP.
For more information, refer to Opsview Knowledge Center - Adding Host Templates to Hosts.
Step 2: Add and configure variables required for this Host Template
The Service Checks in this Host Template use the following variables, and they will be added to your Opsview Monitor instance when you import the Opspack:
HAPROXY
Parameter | Position in Variable | Name | Description | Default Value |
---|---|---|---|---|
-u | Arg1 | Username | HAProxy Username. Override with the same value as your haproxy.cfg file. |
|
-p | Arg2 | Password | HAProxy Password. Override with the same value as your haproxy.cfg file. |
|
-P | Arg3 | Port | HAProxy Port. Override with the same value as your haproxy.cfg file. |
80 |
-s | Arg4 | Stats Path | HAProxy Stats Path. Override with the same value as your haproxy.cfg file. |
haproxy?stats |
HAPROXY_PROXY
You can add multiple variables to check the status of each proxy individually.
Parameter | Position in Variable | Name | Description |
---|---|---|---|
-n | Value | HAProxy Name | Name of the HAProxy you want to monitor. |
For more information, refer to Opsview Knowledge Center - Adding Variables to Hosts.
TLS Certificates
Additionally, you can use the following optional variable to pass in your TLS certificates for use when connecting to the service provider to gather metrics. Ensure that the port given in the HAPROXY variable matches the desired endpoint.
HAPROXY_CERTIFICATES
Parameter | Position in Variable | Name | Description |
---|---|---|---|
--ca-path | Arg1 | CA Certificate Path | Optional path to the CA Certificate (TLS automatically used). |
--client-cert | Arg2 | Client Certificate Path | Optional path to the Client Certificate (TLS automatically used). |
--client-key | Arg3 | Client Key Path | Optional path to the Client Key (TLS automatically used). |
(See Description) | Arg4 | Additional Arguments | Optional extra flags to pass to the plugin script. Flags:
|