HAProxy

HAProxy is a commonly used load-balancer and proxy for TCP and HTTP-based applications that is considered to be fast, reliable, and well-suited for high-traffic websites. We support socket mode and HTTP monitoring mode.

Choosing an HAProxy monitoring mode

We recommend socket mode rather than HTTP mode.

  • Socket mode monitoring:
    • Starting with HAProxy version 1.5-dev13, HAProxy supports splitting processes and mapping them to CPU cores. This enables you to use all your CPU cores.
    • Multiple HAProxy process, socket, and process bindings can be automatically detected. Socket and process bindings are read from an HAProxy configuration file.
  • HTTP mode monitoring:
    • Simpler to configure but less powerful
    • Does not support multiple HAProxy processes
    • When traffic is overwhelming, HAProxy can block HTTP statistics

Socket mode monitoring

HAProxy socket mode monitoring supports global (applicable to all hosts) and local (applicable to specific hosts only) configuration.

Prerequisites for socket mode

  • HAProxy 1.5 or higher
  • Dynatrace OneAgent version 1.113+
  • Dynatrace User (dtuser) with read privileges in the HAProxy configuration file
  • Dynatrace User (dtuser) with read/write privileges in stats sockets
  • Stats socket located in a directory in which Dynatrace User (dtuser) has execute permissions
  • Important: one socket for each running process

Configuring socket mode

Sample code for an HAProxy configuration file:

global

stats socket /var/run/haproxy/process1.sock mode 600 level operator process 1 user dtuser
stats socket /var/run/haproxy/process2.sock mode 600 level operator process 2 user dtuser

stats timeout 30s
nbproc 2

Skipping admin socket

From OneAgent version 1.165, you can use #DYNATRACE.SKIP in the HAProxy configuration file to mark sockets used for administration that you want Dynatrace to ignore. Dynatrace will not use the line following #DYNATRACE.SKIP. In this example, admin.sock will not be used to gather statistics.

global

stats socket /var/run/haproxy/process1.sock mode 600 level operator process 1 user dtuser
stats socket /var/run/haproxy/process2.sock mode 600 level operator process 2 user dtuser

#DYNATRACE.SKIP
stats socket /var/run/haproxy/admin.sock mode 660 level admin

stats timeout 30s
nbproc 2

Activating HAProxy monitoring globally in socket mode

  1. In the navigation menu, select Settings.

  2. Select Monitoring > Monitored technologies.

  3. Find the HAProxy entry.

  4. Set the Global monitoring switch for HAProxy to the On position.

    Note

    Leave User, Password, and URL empty for socket mode.

After you turn HAProxy monitoring on globally, Dynatrace automatically activates HAProxy monitoring on all hosts and monitors all HAProxy components. When a new host running HAProxy is detected in the future, monitoring will be activated and metrics will be gathered automatically.

Activating HAProxy monitoring per host in socket mode

If you previously turned HAProxy global monitoring on, you must turn global monitoring off before you turn monitoring on per host. Navigate to Settings > Monitored technologies, find the HAProxy entry, and set the Global monitoring switch for HAProxy to the Off position.

To activate socket-mode monitoring per host:

  1. In the navigation menu, select Settings.
  2. Select Monitoring > Monitoring overview.
  3. Select the Hosts tab.
  4. Find the host on which you want to monitor HAProxy and open it for editing.
  5. When the Monitored technologies table for the selected host is populated (it may take a moment), find the HAProxy entry.
  6. Set the Monitoring switch for HAProxy on this host to the On position.
    Leave User, Password, and URL empty for socket mode.

After you turn HAProxy monitoring on for a host, Dynatrace automatically activates HAProxy monitoring on that host and monitors all HAProxy components on it.

HTTP mode monitoring

HAProxy HTTP mode monitoring supports global (applicable to all hosts) and local (applicable to specific hosts only) configuration.

Prerequisites for HTTP mode

  • Dynatrace OneAgent version 1.113+
  • HAProxy v1.4 (or higher)
  • HTTP stats enabled

Activating HAProxy monitoring globally in HTTP mode

  1. In the navigation menu, select Settings.
  2. Select Monitoring > Monitored technologies.
  3. Find and expand the HAProxy entry.
  4. Depending on your HAProxy settings, enter either the User, Password, and URL (for example, http://localhost:1936/haproxy?stats) or simply enter a URI prefix.
  5. Select Save.
  6. Set the Global monitoring switch for HAProxy to the On position.

After you turn HAProxy monitoring on globally, Dynatrace automatically activates HAProxy monitoring on all hosts and monitors all HAProxy components. When a new host running HAProxy is detected in the future, monitoring will be activated and metrics will be gathered automatically.

Activating HAProxy monitoring per host in HTTP mode

If you previously turned HAProxy global monitoring on, you must turn global monitoring off before you turn monitoring on per host. Navigate to Settings > Monitored technologies, find the HAProxy entry, and set the Global monitoring switch for HAProxy to the Off position.

To activate HTTP-mode monitoring per host:

  1. In the navigation menu, select Settings.
  2. Select Monitoring > Monitoring overview.
  3. Select the Hosts tab.
  4. Find the host on which you want to monitor HAProxy and open it for editing.
  5. When the Monitored technologies table for the selected host is populated (it may take a moment), find the HAProxy entry and expand it for editing.
  6. Depending on your HAProxy settings, enter either the User, Password, and URL (for example, http://localhost:1936/haproxy?stats) or simply enter a URI prefix.
  7. Select Save.
  8. Set the Monitoring switch for HAProxy on this host to the On position.

After you turn HAProxy monitoring on for a host, Dynatrace automatically activates HAProxy monitoring on that host and monitors all HAProxy components on it.

Configuring HAProxy anomaly detection

Plugin events listed on Settings > Anomaly detection > Plugin events page.

  • High HAProxy requests queue
    Raise an alert if Queued requests is detected to be above the threshold value of x count/min for y minutes during any z minute period.
  • High frontend session usage
    Raise an alert if Frontend session usage is detected to be above the threshold value of x% for y minutes during any z minute period.
  • High HAProxy frontend session usage
    Raise an alert if Frontend session usage is detected to be above the threshold value of x% for y minutes during any z minute period.
  • Low HAProxy idle time
    Raise an alert if Idle is detected to be below the threshold value of x% for y minutes during any z minute period.
  • High HAProxy response time
    Raise an alert if Response time is detected to be above the threshold value of x [ microseconds | milliseconds | seconds | minutes | hours ] for y minutes during any z minute period.
  • High HAProxy backend session usage
    Raise an alert if Backend session usage is detected to be above the threshold value of x% for y minutes during any z minute period.

Docker support

Dynatrace supports HAProxy running inside Docker containers with the following requirements:

  • Dynatrace OneAgent version 1.159+
  • HAProxy Docker image version 1.7+
  • For HTTP mode, you need to expose the port that's used for HTTP queries.
    Example: docker run haproxy -p 1936:1936
  • For socket mode, no further configuration is required.
    Example: docker run haproxy

HAProxy monitoring metrics

HAProxy metrics captured by the HAProxy monitoring plugin are displayed on all HAProxy process pages. Click into the infographic or click the HAProxy metrics and Further details tabs to view all available metrics.

Metric Frontend? Backend? Description
Requests x HTTP requests per second.
Current sessions x x Number of sessions created per second.
Request errors x Some possible causes:
  • Early termination from the client (before the requests was sent)
  • Read error from the client
  • Client timed out
  • Client closed the connection
  • Various bad requests from the client
Queued requests x The current number of queued requests. For the backend, this is the number of requests queued with no server assigned.
Connection errors x The number of requests that encountered an error trying to connect to a backend server. This is the sum of the statistic for all servers for that backend, plus any connection errors not associated with a particular server (such as the backend having no servers).
Response errors x Response errors include:
  • Data transfer aborted by servers
  • Write error on the client sockets
  • Failure applying filters to a response
Bytes received x x The average incoming bytes per second.
Bytes transmitted x x The average outgoing bytes per second.