Alerts and monitoring
Monitor URI
On this page
You can use the monitor-uri
and monitor fail
directives in a frontend
section to present a webpage that monitoring software like Nagios, Icinga or others can check periodically to know the state of the load balancer.
Enable the monitoring page Jump to heading
Below, we enable the monitoring webpage:
haproxy
frontend wwwbind :80monitor-uri /checkstatusmonitor fail if { nbsrv(webservers) eq 0 }default_backend webserversbackend webserversbalance roundrobinserver server1 10.0.1.3:80 checkserver server2 10.0.1.4:80 check
haproxy
frontend wwwbind :80monitor-uri /checkstatusmonitor fail if { nbsrv(webservers) eq 0 }default_backend webserversbackend webserversbalance roundrobinserver server1 10.0.1.3:80 checkserver server2 10.0.1.4:80 check
In this example:
- The
monitor-uri
directive’s value is a URL path that does not map to any resource on your backend servers. The load balancer will respond with an HTTP200 OK
whenever the monitoring software requests this URL path. In this example, we present a page at/checkstatus
that monitoring software can request periodically. - The
monitor fail
directive returns an HTTP503 Service Unavailable
response if a given condition is true. In this case, the condition checks whether thewebservers
backend has zero healthy servers up.
Use them both together
Always use these two directives together.
- If you use
monitor-uri
alone, the monitoring software always receives a200 OK
response, which reveals only that the load balancer is running but does not indicate the health of the backend servers. - If you use
monitor fail
alone, there is no effect.
You can have only one monitor-uri
directive, but you can have multiple monitor fail
directives, each specifying different conditions.
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?