Searching HAProxy Enterprise 1.7r2
Generating Alerts for Events
Generating Alerts for Events
HAProxy can generate alerts through syslog or emails to notify the administrator of HAProxy events.
Events are generated based on syslog levels from debug to emergency.
Alerts are sent when:
An un-paused server is marked as down and <level> is 'alert' or lower
A paused server is marked as down and <level> is 'notice' or lower
A server is marked as up or enters the drain state and <level> is 'notice' or lower
The service
option log-health-checks
is enabled with <level> as 'info' or lower, and a health check status update occurs
Using emails for alerts
To use emails for alerts, you first configure a mailers section where you define some message transfer agents (MTA) servers.
Then in the back end section, you define options for the emails to send out. Emails are sent using the SMTP protocol.
Create the mailers section
To create a new mailers
section, add the following line:
mailers <mailersectionname>
where <mailersectionname>
is the name of your mailers section which later serves as a label.
Note
You can define several mailers sections in a single HAProxy configuration.
To configure additional mailer servers, add the following line:
mailers <mailersectionname>
mailer <mailername> <ip>:<port>
with the following parameters:
| mail server name |
| mail server IP address |
| TCP port where the SMTP service runs on the server |
Example of a mailers section configuration
mailers mta
mailer smtp1 10.0.0.1:25
mailer smtp2 10.0.0.2:25
Configure options for emails
You can configure the following sections to use emails for alerts: defaults, frontend, backend, or listen as follows:
| declares the email sender address, also known as FROM for use in both the envelopes and headers. |
| declares the maximum log level of messages for which email alerts will go out; |
| the mailers section to use to send emails |
| hostname address to use when communicating with mailers; by default, it is the system hostname. |
| declares the recipient address for both the envelope and the header. |
Send an email when a server is DOWN
mailers mta
mailer smtp1 10.0.0.1:25
mailer smtp2 10.0.0.2:25
backend b_myapp
# ...
email-alert mailers mta
email-alert level alert
email-alert from haproxy@dmydomain.com
email-alert to ops@mydomain.com