---
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.

## Enable the stats endpoint

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

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

```none
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:

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

```none
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:

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

```none
sudo systemctl reload haproxy
```

Verify the endpoint is accessible by running:

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

```none
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`).
