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.

Configuration snippets for Grafana Alloy

Simple mode

These snippets are configured to scrape a single HAProxy instance running locally with default ports.

First, manually copy and append the following snippets into your alloy configuration file.

Metrics snippets

alloy
discovery.relabel "metrics_integrations_integrations_haproxy" {
	targets = [{
		__address__ = "localhost:8404",
	}]

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "metrics_integrations_integrations_haproxy" {
	targets    = discovery.relabel.metrics_integrations_integrations_haproxy.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/haproxy"
}

Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your HAProxy instances, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

Advanced metrics snippets

alloy
discovery.relabel "metrics_integrations_integrations_haproxy" {
	targets = [{
		__address__ = "localhost:8404",
	}]

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}
}

prometheus.scrape "metrics_integrations_integrations_haproxy" {
	targets    = discovery.relabel.metrics_integrations_integrations_haproxy.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/haproxy"
}

To monitor your HAProxy instance, you must use a discovery.relabel component to discover your HAProxy Prometheus endpoint and apply appropriate labels, followed by a prometheus.scrape component to scrape it.

Configure the following properties within each discovery.relabel component:

  • __address__: The address to your HAProxy Prometheus metrics endpoint.
  • instance label: constants.hostname sets the instance label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this HAProxy instance.

If you have multiple HAProxy servers to scrape, configure one discovery.relabel for each and scrape them by including each under targets within the prometheus.scrape component.

Grafana Agent static configuration (deprecated)

The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.

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
  • up

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.