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 or Icinga) can check periodically to know the state of the load balancer.
Enable the monitoring page Jump to heading
Below, we enable the monitoring webpage:
haproxyfrontend 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
haproxyfrontend 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-uridirective’s value is a URL path that doesn’t map to any resource on your backend servers. The load balancer will respond with an HTTP200 OKwhenever the monitoring software requests this URL path. In this example, we present a page at/checkstatusthat monitoring software can request periodically. - The
monitor faildirective returns an HTTP503 Service Unavailableresponse if a given condition is true. In this case, the condition checks whether thewebserversbackend has zero healthy servers up.
Use them both together
Always use these two directives together.
- If you use
monitor-urialone, the monitoring software always receives a200 OKresponse, which reveals only that the load balancer is running but doesn’t indicate the health of the backend servers. - If you use
monitor failalone, 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
For complete information on the directives used in monitoring, see these topics in the HAProxy Configuration Manual.
- To specify a condition that reports a failure, see monitor fail.
- To define a URI to be used only for monitoring from an external source, see monitor-uri.
Do you have any suggestions on how we can improve the content of this page?