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.
Open your HAProxy configuration file (typically /etc/haproxy/haproxy.cfg) and add this frontend. It serves the stats page at /stats and Prometheus metrics at /metrics on port 8404, which is the address the Grafana Cloud snippet scrapes:
frontend stats
bind *:8404
http-request use-service prometheus-exporter if { path /metrics }
stats enable
stats uri /stats
stats refresh 10sThe built-in Prometheus exporter requires HAProxy 2.0 or later. If you are running an older version, you need to use an external exporter.
After saving the configuration changes, reload HAProxy to apply them:
sudo systemctl reload haproxyVerify the metrics endpoint is accessible by running:
curl http://localhost:8404/metricsYou 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).