Skip to content

Monitoring guide

HAProxy monitoring: backends, errors and queues

HAProxy knows the health of every backend and every request it forwards. Its stats tell you when servers go down, queues build and errors rise.

4 min read13 sectionsUpdated

On this page

Key points

  • Backend servers DOWN is the first alert.
  • Queue (qcur) above zero means backends are saturated.
  • 5xx from backends vs from HAProxy tells you where the fault is.
  • Session limits cap concurrency.

Enable stats

haproxy.cfgplaintext
frontend stats
    bind 127.0.0.1:8404
    http-request use-service prometheus-exporter if { path /metrics }
    stats enable
    stats uri /stats
    stats refresh 10s

What to watch

MetricWorry when
Server status per backendAny server DOWN; all servers DOWN is an outage
Current queue (qcur)Above 0 for minutes
Sessions current vs limitNear the limit
HTTP 5xx rateRising; check whether from backends or HAProxy itself
Response time (rtime) / total time (ttime)Rising backend response time
Health check failuresFlapping servers

Collecting metrics

otel-collector.yamlyaml
receivers:
  haproxy:
    endpoint: http://127.0.0.1:8404/stats
    collection_interval: 60s
exporters:
  otlphttp/vitalrix:
    encoding: json
    metrics_endpoint: ${env:VITALRIX_API}/api/v1/metrics/otlp/v1/metrics
    headers: { x-api-key: ${env:VITALRIX_KEY} }
service:
  pipelines:
    metrics: { receivers: [haproxy], exporters: [otlphttp/vitalrix] }

HAProxy monitoring with VitalRix

Collector metrics arrive over OTLP and can be charted on dashboards and used in alert rules. A TCP check confirms HAProxy accepts connections from the network your app uses, and APM traces show which requests wait on HAProxy and for how long, from the client spans your instrumented services create. Uptime checks on the public URLs behind HAProxy confirm what users see. See 502 Bad Gateway and 503 Service Unavailable.

HAProxy logs and timers

HAProxy's HTTP log line includes timers (Tq/Tw/Tc/Tr/Ta): time to receive the request, time waiting in queue, time to connect to the server, server response time and total time, plus termination flags that say why a connection ended. High Tw means queueing; high Tc means trouble reaching servers; high Tr means slow backends. Ship the logs and chart these fields; they explain most slowdowns at a glance.

Alerts to start with

  • Any backend with all servers DOWN, immediately.
  • A server DOWN for more than 5 minutes.
  • Queue current above 0 for 5 minutes.
  • Backend 5xx share above 1 to 2%.
  • Sessions above 80% of the configured limit.

Reloads and deploys

HAProxy reloads are seamless when configured with the master-worker mode and socket transfer, but a bad config still stops the reload. Validate with haproxy -c -f haproxy.cfg in your pipeline, and watch error rates right after each reload.

The HAProxy metrics that matter

HAProxy 2.0 and later can serve Prometheus metrics itself (http-request use-service prometheus-exporter on a stats frontend); older versions expose the stats page and the runtime socket.

MetricStats fieldStarting alert
Backend servers upstatus per serverAny server DOWN; all servers down is an outage
Queued requestsqcurAbove zero for a minute: servers are at maxconn
Sessions vs limitscur vs slimAbove 80%
5xx responseshrsp_5xxAbove 1% for 5 minutes
Retries and redispatcheswretr, wredisA rising rate
Response timertime / ttimeRising against the usual
plaintext
frontend stats
  bind 127.0.0.1:8404
  http-request use-service prometheus-exporter if { path /metrics }
  stats enable
  stats uri /stats

backend app
  option httpchk GET /health
  server app1 10.0.0.11:8080 check inter 5s fall 3 rise 2 maxconn 200

What the incidents look like

  • A health check that is too shallow: the check passes while the application returns errors, so HAProxy keeps sending traffic to a broken server. Make /health exercise the dependencies that matter.
  • A check that is too strict: a slow database makes every server fail the check at once, and HAProxy takes the whole backend down. Separate liveness from deep checks.
  • Queues build at maxconn during a spike, and response times climb before any error appears.
  • Uneven load after a server is added, with sticky sessions keeping old clients on old servers.

Always pair load balancer metrics with an external uptime check: HAProxy reports its backends, not what users see.

Frequently asked questions

Why does HAProxy return 503?

No backend server is available (all DOWN or at maxconn with a full queue), or a request was denied. The stats page shows which.

Should the stats page be public?

No. Bind it to localhost or an internal network and protect it.

  • The RED method: The RED method explained: rate, errors and duration for every service, how to compute each from traces, a dashboard layout and the alerts worth setting.
  • WordPress monitoring: uptime, speed and errors: Monitor a WordPress site: uptime with content checks, login and admin, Core Web Vitals, PHP errors, plugin updates, SSL expiry and backups.
  • RabbitMQ monitoring: queues, consumers and alarms: Monitor RabbitMQ: queue depth and message rates, unacknowledged messages, consumer counts, memory and disk alarms, and connection churn, with commands.
  • Monitoring for game backends: Monitor game backends and launchers: login and matchmaking latency, store and payment APIs, regional performance, launch-day spikes.
  • The Cloudflare outage of November 2025, explained: Why Cloudflare returned errors for hours on 18 November 2025: a permission change doubled a bot-management file past a limit, and the lessons.
  • OpenTelemetry backends compared: Where to send OpenTelemetry data in 2026: open-source and commercial backends compared on OTLP support, views, cost and hosting, with criteria for choosing one.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.