Technology
HAProxy
Monitor HAProxy load balancer and proxy performance, including connection rates, request queuing, session counts, and backend server health.
Overview
Overview
HAProxy is a widely-used open-source load balancer and proxy server for TCP and HTTP-based applications. It is known for its high performance, reliability, and rich feature set for routing and distributing traffic across backend servers — from small deployments to large-scale infrastructure handling millions of connections.
Monitoring HAProxy is essential for understanding traffic distribution, detecting backend failures early, and ensuring your load balancing layer is not itself a bottleneck. The Dash0 integration collects metrics directly from HAProxy's stats interface via the OpenTelemetry Collector.
Use Cases
- Monitor Connection Rates and Errors: Track active connections, connection rates, and connection errors across frontends and backends to catch saturation or network issues early.
- Track Request Queuing and Redispatching: Observe queued request counts and redispatch events to identify overloaded backend pools before they impact end users.
- Analyze Session Counts and Saturation: Monitor current session counts against configured limits to detect when HAProxy is approaching capacity.
- Understand Traffic Throughput: Measure bytes in and out across frontends and backends to profile traffic patterns and plan capacity.
- Detect Backend Server Issues: Surface response errors, connection retries, and server selection failures to quickly identify unhealthy upstream servers.
Setup
Overview
The OpenTelemetry Collector's HAProxy receiver polls HAProxy periodically through either a Unix domain socket or an HTTP stats URL, collecting metrics about frontends, backends, and server health. The collector then forwards these metrics to Dash0.
Prerequisites
Before setting up HAProxy monitoring, ensure:
- HAProxy 2.0 or later is running and accessible
- HAProxy's stats interface is enabled (socket or HTTP — see below)
- OpenTelemetry Collector is deployed using the OpenTelemetry Collector Contrib distribution
You'll need an OpenTelemetry Collector deployed in your environment. Consider using:
Enable HAProxy Stats
The receiver requires HAProxy's stats interface to be enabled. Choose one of the following approaches:
Option A: Unix Socket (recommended for non-Kubernetes)
Add the following to the global section of your haproxy.cfg:
global
stats socket /var/run/haproxy/haproxy.sock mode 660 level admin expose-fd listeners
stats timeout 30sOption B: HTTP Stats Page (recommended for Kubernetes)
Add a dedicated stats frontend to your haproxy.cfg:
frontend stats
bind *:8404
stats enable
stats uri /stats
stats refresh 10s
no logRestart HAProxy after making configuration changes:
systemctl reload haproxyCollector Configuration
Add the HAProxy receiver to your OpenTelemetry Collector configuration:
receivers:
haproxy:
# Use the socket path or HTTP URL matching your HAProxy configuration
endpoint: file:///var/run/haproxy/haproxy.sock
# For HTTP stats page, use:
# endpoint: http://127.0.0.1:8404/stats
collection_interval: 1mWire the receiver into a pipeline:
service:
pipelines:
metrics:
receivers: [haproxy]
processors: [batch]
exporters: [otlp]Configuration Options
endpoint(required): Path to the HAProxy stats interface. Usefile://prefix for a Unix socket or a full HTTP URL for the stats page.collection_interval: How often to poll HAProxy for metrics. Default:1m.initial_delay: Delay before the first collection. Default:1s.metrics: Optionally enable or disable individual metrics. All 17 default metrics are enabled automatically.
For all available options, see the HAProxy receiver documentation.
Kubernetes: Mounting the Stats Socket
If using a Unix socket in Kubernetes, mount the socket path as a hostPath volume in your collector DaemonSet:
volumes:
- name: haproxy-socket
hostPath:
path: /var/run/haproxy
volumeMounts:
- name: haproxy-socket
mountPath: /var/run/haproxyFor most Kubernetes setups, the HTTP stats page approach (Option B) is simpler.
Verification
- Check the collector logs for successful connections to HAProxy
- Navigate to the Metrics Explorer in Dash0
- Search for metrics with the prefix
haproxy.* - Confirm key metrics are visible:
haproxy.requests.total— cumulative request count per backendhaproxy.sessions.count— current active sessionshaproxy.connections.rate— new connections per secondhaproxy.bytes.input/haproxy.bytes.output— traffic throughputhaproxy.responses.errors— backend error responses
