> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
> Use this file to discover all available pages before exploring further.

# HAProxy logs and metrics with OpenTelemetry

> Collect HAProxy access logs and proxy metrics — request latency, status codes, and backend health — with the OpenTelemetry Collector and Prometheus.

Collect HAProxy access logs — frontend/backend connections, timing, and status codes — with the OpenTelemetry Collector. HAProxy emits logs over syslog, so the usual setup is HAProxy → rsyslog → a file the Collector tails. The same Collector can also forward traces and metrics from your apps — see [Connect OpenTelemetry Collector to Bronto](/agent-setup/open-telemetry).

## Prerequisites

* A Bronto account and API key ([how to create one](/Account-Management/API-Keys#create-a-new-api-key))
* HAProxy logging to local syslog (`log 127.0.0.1 local0` in `haproxy.cfg`), with rsyslog writing `local0` to `/var/log/haproxy.log`
* An [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/installation/) (recommended) or [Fluent Bit](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit) installed on the same host

## Configure the Collector

```yaml /etc/otel/config.yaml theme={"dark"}
receivers:
  filelog/haproxy:
    include:
      - /var/log/haproxy.log
    resource:
      service.name: haproxy
      service.namespace: <YOUR_COLLECTION_NAME>

processors:
  batch:

exporters:
  otlphttp/brontologs:
    logs_endpoint: "https://ingestion.<REGION>.bronto.io/v1/logs"
    compression: gzip
    headers:
      x-bronto-api-key: <YOUR_API_KEY>

service:
  pipelines:
    logs:
      receivers: [filelog/haproxy]
      processors: [batch]
      exporters: [otlphttp/brontologs]
```

Set `<REGION>` to `eu` or `us`. No rsyslog on the host? Receive HAProxy's syslog stream directly with the OTel Collector's `syslog` receiver instead of `filelog`.

## Metrics

HAProxy 2.0 and later can expose Prometheus metrics through its built-in `prometheus-exporter` service. Enable a stats listener, then scrape it with the Collector's `prometheus` receiver:

```text haproxy.cfg theme={"dark"}
frontend prometheus
  bind 127.0.0.1:8404
  mode http
  http-request use-service prometheus-exporter if { path /metrics }
  no log
```

```yaml theme={"dark"}
receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: haproxy
          metrics_path: /metrics
          static_configs:
            - targets: [localhost:8404]
```

Add this receiver to the [Bronto metrics pipeline](/metrics/send-metrics). See the [Collector Contrib Prometheus receiver documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver) for scrape configuration. Older HAProxy releases require a separate exporter or the [Collector Contrib HAProxy receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/haproxyreceiver) against a compatible stats endpoint.

## What you will see in Bronto

Open [Search](https://app.bronto.io/search) and filter by `service.name = haproxy`. The HTTP log format includes the client IP, the frontend and backend names, the chosen server, connection and response timers (queue, connect, response, total), the status code, bytes, and the session termination state. Bronto's [Custom Parser](/core-features/custom-parser) has built-in HAProxy support, so these fields are extracted automatically.

## Troubleshooting

* **No logs?** Confirm `log 127.0.0.1 local0` is set in `haproxy.cfg` and that rsyslog routes `local0.*` to `/var/log/haproxy.log`, then restart both services.
* For general issues, see [OTel Collector troubleshooting](https://opentelemetry.io/docs/collector/troubleshooting/).

## Alternative: Fluent Bit

If you already run Fluent Bit, tail the HAProxy log file and forward it over HTTP:

```ini fluent-bit.conf theme={"dark"}
[INPUT]
    name  tail
    path  /var/log/haproxy.log
    tag   haproxy

[OUTPUT]
    name        http
    match       haproxy
    host        ingestion.<REGION>.bronto.io
    port        443
    tls         on
    format      json_lines
    compress    gzip
    header      x-bronto-api-key    <YOUR_API_KEY>
    header      x-bronto-dataset    haproxy
    header      x-bronto-collection <YOUR_COLLECTION_NAME>
```

Set **Format** to `json_lines`, not `json`. See [Connect Fluent Bit to Bronto](/agent-setup/fluent-bit) for installation.
