Configure HAProxy to expose the stats endpoint

Before Grafana Alloy can collect HAProxy metrics, you need to enable the HAProxy stats endpoint. This endpoint exposes real-time metrics about frontends, backends, and individual servers in a format that Alloy can scrape.

This step happens on your HAProxy server, not in the Grafana Cloud UI.

Enable the stats endpoint

Open your HAProxy configuration file (typically /etc/haproxy/haproxy.cfg) and add a listen stats section:

listen stats
    bind *:8404
    stats enable
    stats uri /stats
    stats refresh 10s

This configuration:

  • Binds the stats endpoint to port 8404
  • Enables the stats page at /stats
  • Refreshes stats every 10 seconds

Enable the Prometheus endpoint

The HAProxy integration uses the Prometheus-compatible metrics endpoint. Add the following to the same listen stats section or as a separate frontend:

frontend prometheus
    bind *:8405
    http-request use-service prometheus-exporter if { path /metrics }
    no log

Note: The built-in Prometheus exporter requires HAProxy 2.0 or later. If you are running an older version, you need to use an external exporter.

Reload HAProxy

After saving the configuration changes, reload HAProxy to apply them:

sudo systemctl reload haproxy

Verify the endpoint is accessible by running:

curl http://localhost:8405/metrics

You should see Prometheus-formatted metrics. If the endpoint is not reachable, check that the port is open in your firewall and that HAProxy reloaded without errors (sudo systemctl status haproxy).


page 5 of 10