---
title: "Configure HAProxy to expose the stats endpoint | Grafana Labs"
description: "Enable the HAProxy stats and Prometheus endpoints so Grafana Alloy can collect metrics"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# 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:

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
frontend stats
   bind *:8404
   http-request use-service prometheus-exporter if { path /metrics }
   stats enable
   stats uri /stats
   stats refresh 10s
```

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.

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

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
sudo systemctl reload haproxy
```

Verify the metrics endpoint is accessible by running:

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
curl http://localhost:8404/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`).
