Menu
Grafana Cloud

HAProxy integration for Grafana Cloud

HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for very high traffic web sites and powers quite a number of the world’s most visited ones. Over the years it has become the de-facto standard opensource load balancer, is now shipped with most mainstream Linux distributions, and is often deployed by default in cloud platforms. This integration allows you to collect metrics from the HAProxy instance and visualize them through pre-built dashboard in Grafana cloud.

This integration includes 3 useful alerts and 4 pre-built dashboards to help monitor and visualize HAProxy metrics.

Before you begin

This integration monitors an HAProxy Server app that exposes metrics through the built-in HAProxy Prometheus Exporter which can be built into the version 2.x+ binary.

A frontend configuration which is compatible with your existing HAProxy configuration is required. This configuration can be used as an example.

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

Install HAProxy integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find HAProxy and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send HAProxy metrics to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your HAProxy setup.

Post-install configuration for the HAProxy integration

After enabling the metrics generation, instruct Grafana Agent to scrape your HAProxy nodes.

HAProxy exposes a /metrics endpoint. To scrape it, add the provided snippet to your agent configuration file.

Make sure to change targets in the snippet according to your environment.

Configuration snippets for Grafana Agent

Below metrics.configs.scrape_configs, insert the following lines and change the URLs according to your environment:

yaml
    - job_name: integrations/haproxy
      static_configs:
        - targets: ['localhost:8404']
      relabel_configs:          
        - action: replace
          replacement: '<your-instance-name>'
          target_label: instance

Full example configuration for Grafana Agent

Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the HAProxy integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.

yaml
integrations:
  prometheus_remote_write:
  - basic_auth:
      password: <your_prom_pass>
      username: <your_prom_user>
    url: <your_prom_url>
  agent:
    enabled: true
    relabel_configs:
    - action: replace
      source_labels:
      - agent_hostname
      target_label: instance
    - action: replace
      target_label: job
      replacement: "integrations/agent-check"
    metric_relabel_configs:
    - action: keep
      regex: (prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
      source_labels:
      - __name__
  # Add here any snippet that belongs to the `integrations` section.
  # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
logs:
  configs:
  - clients:
    - basic_auth:
        password: <your_loki_pass>
        username: <your_loki_user>
      url: <your_loki_url>
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
      # Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: <your_prom_pass>
        username: <your_prom_user>
      url: <your_prom_url>
    scrape_configs:
      # Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
    - job_name: integrations/haproxy
      static_configs:
        - targets: ['localhost:8404']
      relabel_configs:          
        - action: replace
          replacement: '<your-instance-name>'
          target_label: instance
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal

Dashboards

The HAProxy integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • HAProxy / Backend
  • HAProxy / Frontend
  • HAProxy / Overview
  • HAProxy / Server

Alerts

The HAProxy integration includes the following useful alerts:

AlertDescription
HAProxyDroppingLogsWarning: HAProxy is dropping logs.
HAProxyBackendCheckFlappingWarning: HAProxy backend checks are flapping.
HAProxyServerCheckFlappingWarning: HAProxy server checks are flapping.

Metrics

The most important metrics provided by the HAProxy integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

  • haproxy_backend_bytes_in_total
  • haproxy_backend_bytes_out_total
  • haproxy_backend_check_up_down_total
  • haproxy_backend_connect_time_average_seconds
  • haproxy_backend_connection_attempts_total
  • haproxy_backend_connection_errors_total
  • haproxy_backend_http_requests_total
  • haproxy_backend_internal_errors_total
  • haproxy_backend_max_connect_time_seconds
  • haproxy_backend_max_queue_time_seconds
  • haproxy_backend_max_response_time_seconds
  • haproxy_backend_max_total_time_seconds
  • haproxy_backend_queue_time_average_seconds
  • haproxy_backend_response_errors_total
  • haproxy_backend_response_time_average_seconds
  • haproxy_backend_status
  • haproxy_backend_total_time_average_seconds
  • haproxy_frontend_bytes_in_total
  • haproxy_frontend_bytes_out_total
  • haproxy_frontend_connections_total
  • haproxy_frontend_http_requests_total
  • haproxy_frontend_internal_errors_total
  • haproxy_frontend_request_errors_total
  • haproxy_frontend_status
  • haproxy_process_current_connections
  • haproxy_process_dropped_logs_total
  • haproxy_process_limit_connection_rate
  • haproxy_process_limit_session_rate
  • haproxy_process_limit_ssl_rate
  • haproxy_process_max_connections
  • haproxy_process_max_fds
  • haproxy_process_max_memory_bytes
  • haproxy_process_max_pipes
  • haproxy_process_max_sockets
  • haproxy_process_nbproc
  • haproxy_process_nbthread
  • haproxy_process_pool_allocated_bytes
  • haproxy_process_pool_used_bytes
  • haproxy_process_start_time_seconds
  • haproxy_server_bytes_in_total
  • haproxy_server_bytes_out_total
  • haproxy_server_check_up_down_total
  • haproxy_server_connect_time_average_seconds
  • haproxy_server_connection_attempts_total
  • haproxy_server_connection_errors_total
  • haproxy_server_http_responses_total
  • haproxy_server_internal_errors_total
  • haproxy_server_max_connect_time_seconds
  • haproxy_server_max_queue_time_seconds
  • haproxy_server_max_response_time_seconds
  • haproxy_server_max_total_time_seconds
  • haproxy_server_queue_time_average_seconds
  • haproxy_server_response_errors_total
  • haproxy_server_response_time_average_seconds
  • haproxy_server_status
  • haproxy_server_total_time_average_seconds

Changelog

md
# 1.0.0 - February 2024

* Update mixin to replace all Angular panels with React based panels.

# 0.0.5 - August 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.4 - January 2023

* Update mixin to the latest version
  - Update alert severity
  - Update dashboard labels


# 0.0.3 - September 2022

* Update dashboard panels.

# 0.0.2 - October 2021

* Update mixin to latest version:
  - Update the datasource template variable label to 'Data Source'

# 0.0.1 - April 2021

* Initial release

Cost

By connecting your HAProxy instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.