OpenTelemetry

Install the HAProxy OpenTelemetry filter

This page applies to:

  • HAProxy 3.4 and newer
  • HAProxy Enterprise 3.2r1 and newer

To begin collecting OpenTelemetry data from your load balancer, you must install the filter. This page describe the steps.

It also explains how to run OpenTelemetry Collector to test your installation. OpenTelemetry Collector is suitable for test and production environments, although in production you’ll want to run it on a separate server from your load balancer. It can print telemetry data to the console so you can quickly verify that everything works. Or use it to relay data to other software such as Jaeger and Prometheus, which let you visualize traces, metrics, and logs.

Install the OpenTelemetry filter Jump to heading

Installing the HAProxy OpenTelemetry filter varies depending on the product. The table below tells you where to go.

Product Install steps
HAProxy The filter is included in the HAProxy OpenTelemetry C library. Compile HAProxy from source while including the HAProxy OpenTelemetry library. This library depends on the HAProxy C Wrapper library and the OpenTelemetry C++ client library. For compilation steps, see the HAProxy OpenTelemetry GitHub project.
HAProxy Enterprise The filter is part of the HAProxy Enterprise OpenTelemetry module. See the OpenTelemetry module guide.

Once installed, you can run OpenTelemetry Collector to verify that everything works. Also, check out the tutorials to learn how to configure traces, logs, and metrics.

Run OpenTelemetry Collector Jump to heading

OpenTelemetry Collector provides a vendor-agnostic way to receive, process, and export telemetry data. You can send your traces, logs, and metrics to it to see the data as it streams in. Simply configure its debug exporter, which prints to the console. Or, configure Collector to relay data to any software that supports the OpenTelemetry protocol, including Elasticsearch, Jaeger, Prometheus, and others. For a full list, see the OpenTelemetry Registry.

In this tutorial, we’ll run OpenTelemetry Collector by using Docker Compose.

  1. Install Docker and Docker Compose by following the official guide, Install Docker Engine.

  2. Create a Docker Compose file that runs OpenTelemetry Collector as a container. In this example, we expose it at port 4318. Also, we run Jaeger and Prometheus as containers to provide destinations for traces and metrics.

    docker-compose.yaml
    yaml
    networks:
    custom_net:
    driver: bridge
    ipam:
    config:
    - subnet: 172.16.0.0/16
    gateway: 172.16.0.1
    services:
    otel-collector:
    image: otel/opentelemetry-collector
    volumes:
    - ./collector-config.yaml:/etc/otelcol/config.yaml
    ports:
    - 4318:4318 # OTLP http receiver
    networks:
    custom_net:
    ipv4_address: 172.16.0.12
    # Send traces to Jaeger at 172.16.0.13:4318
    jaeger:
    image: jaegertracing/jaeger
    ports:
    - "16686:16686"
    - "16687:16687"
    environment:
    - LOG_LEVEL=debug
    networks:
    custom_net:
    ipv4_address: 172.16.0.13
    # Send metrics to Prometheus at 172.16.0.14:9090
    prometheus:
    image: prom/prometheus
    ports:
    - "9090:9090"
    volumes:
    - "./prometheus.yaml:/etc/prometheus/prometheus.yml"
    networks:
    custom_net:
    ipv4_address: 172.16.0.14
    docker-compose.yaml
    yaml
    networks:
    custom_net:
    driver: bridge
    ipam:
    config:
    - subnet: 172.16.0.0/16
    gateway: 172.16.0.1
    services:
    otel-collector:
    image: otel/opentelemetry-collector
    volumes:
    - ./collector-config.yaml:/etc/otelcol/config.yaml
    ports:
    - 4318:4318 # OTLP http receiver
    networks:
    custom_net:
    ipv4_address: 172.16.0.12
    # Send traces to Jaeger at 172.16.0.13:4318
    jaeger:
    image: jaegertracing/jaeger
    ports:
    - "16686:16686"
    - "16687:16687"
    environment:
    - LOG_LEVEL=debug
    networks:
    custom_net:
    ipv4_address: 172.16.0.13
    # Send metrics to Prometheus at 172.16.0.14:9090
    prometheus:
    image: prom/prometheus
    ports:
    - "9090:9090"
    volumes:
    - "./prometheus.yaml:/etc/prometheus/prometheus.yml"
    networks:
    custom_net:
    ipv4_address: 172.16.0.14
  3. Create configuration files in the same directory as the docker-compose.yaml file.

    • For OpenTelemetry Collector, create a file named collector-config.yaml.

      collector-config.yaml
      yaml
      receivers:
      otlp:
      protocols:
      http:
      endpoint: 0.0.0.0:4318
      exporters:
      debug:
      verbosity: detailed
      otlp_http:
      # The base URL of your OTLP/HTTP compatible backend (e.g., Jaeger)
      endpoint: "http://172.16.0.13:4318"
      prometheus:
      # publish Prometheus metrics to be scraped
      endpoint: "0.0.0.0:9090"
      service:
      pipelines:
      traces:
      receivers: [otlp]
      exporters: [debug, otlp_http]
      metrics:
      receivers: [otlp]
      exporters: [debug, prometheus]
      logs:
      receivers: [otlp]
      exporters: [debug]
      collector-config.yaml
      yaml
      receivers:
      otlp:
      protocols:
      http:
      endpoint: 0.0.0.0:4318
      exporters:
      debug:
      verbosity: detailed
      otlp_http:
      # The base URL of your OTLP/HTTP compatible backend (e.g., Jaeger)
      endpoint: "http://172.16.0.13:4318"
      prometheus:
      # publish Prometheus metrics to be scraped
      endpoint: "0.0.0.0:9090"
      service:
      pipelines:
      traces:
      receivers: [otlp]
      exporters: [debug, otlp_http]
      metrics:
      receivers: [otlp]
      exporters: [debug, prometheus]
      logs:
      receivers: [otlp]
      exporters: [debug]
    • For Prometheus, create a file named prometheus.yaml.

      prometheus.yaml
      yaml
      # my global config
      global:
      scrape_interval: 15s # Scrape every 15 seconds. Default is every 1 minute.
      scrape_configs:
      - job_name: "prometheus"
      static_configs:
      - targets: ["localhost:9090"]
      - job_name: "opentelemetry"
      scheme: http
      static_configs:
      - targets: ['172.16.0.12:9090']
      prometheus.yaml
      yaml
      # my global config
      global:
      scrape_interval: 15s # Scrape every 15 seconds. Default is every 1 minute.
      scrape_configs:
      - job_name: "prometheus"
      static_configs:
      - targets: ["localhost:9090"]
      - job_name: "opentelemetry"
      scheme: http
      static_configs:
      - targets: ['172.16.0.12:9090']
  4. Start the containers.

    nix
    sudo docker compose up
    nix
    sudo docker compose up

    Once the containers are running, you can see the OpenTelemetry Collector’s debug log in the console; the Jaeger UI listens at HTTP port 16686 and the Prometheus UI listens at port 9090. You won’t see metrics until you add them to your instrumentation.cfg file.

Do you have any suggestions on how we can improve the content of this page? Please leave feedback!