Skip to content

Haproxy

Collection of Haproxy Metrics information.

Installation and Deployment

Version Requirements

  • HAProxy 2.0
  • HAProxy Enterprise 2.0r1
  • HAProxy ALOHA 11.5

1. Enable Haproxy Metrics

Adjust the Haproxy configuration file and add the following module configuration:

frontend prometheus
  bind *:8405
  mode http
  http-request use-service prometheus-exporter if { path /metrics }
  no log
......

Expose Metrics information via prometheus-exporter, port 8405, path /metrics.

Restart the Haproxy service. Access port 8405 to obtain Metrics information, as shown below:

# HELP haproxy_process_nbthread Number of started threads (global.nbthread)
# TYPE haproxy_process_nbthread gauge
haproxy_process_nbthread 8
# HELP haproxy_process_nbproc Number of started worker processes (historical, always 1)
# TYPE haproxy_process_nbproc gauge
haproxy_process_nbproc 1
# HELP haproxy_process_relative_process_id Relative worker process number (1)
# TYPE haproxy_process_relative_process_id gauge
haproxy_process_relative_process_id 1
# HELP haproxy_process_uptime_seconds How long ago this worker process was started (seconds)
# TYPE haproxy_process_uptime_seconds gauge
haproxy_process_uptime_seconds 1364
...

2. DataKit Collector Configuration

2.1 Install DataKit

2.2 Configure Collector

Since Haproxy can directly expose Metrics URLs, it can be collected using the prom collector.

Navigate to the conf.d/prom directory under the DataKit installation directory and copy prom.conf.sample to haproxy.conf.

cp prom.conf.sample haproxy.conf

Modify the contents of haproxy.conf as follows:

  urls = ["http://localhost:8405/metrics"]

  source = "haproxy"

  interval = "10s"
  ...

Other configurations may need adjustment

Parameter adjustment explanation:

  • urls: haproxy Metrics address, fill in the corresponding component's exposed Metrics URL here.
  • source: Collector alias, it is recommended to differentiate.
  • keep_exist_metric_name: Keep the Metrics name.
  • interval: Collection interval.

3. Restart DataKit

Restart DataKit

Metrics

Haproxy Measurement

Metrics Description Unit
backend_bytes_in_total Total backend bytes in byte
backend_bytes_out_total Total backend bytes out byte
backend_client_aborts_total Total backend client aborts count
backend_connect_time_average_seconds Average backend connection time in seconds seconds
backend_connection_attempts_total Total backend connection attempts count
backend_connection_errors_total Total backend connection errors count
backend_connection_reuses_total Total backend connection reuses count
backend_current_queue Current backend queue count
backend_current_sessions Current backend sessions count
backend_internal_errors_total Total backend internal errors count
backend_loadbalanced_total Total backend load balancing count
backend_max_queue Maximum backend queue count
backend_max_sessions Maximum backend sessions count
backend_requests_denied_total Total backend requests denied count
backend_response_errors_total Total backend response errors count
backend_responses_denied_total Total backend responses denied count
backend_retry_warnings_total Total backend retry warnings count
backend_server_aborts_total Total backend server aborts count
backend_sessions_total Total backend sessions count
frontend_bytes_in_total Total frontend bytes in byte
frontend_bytes_out_total Total frontend bytes out byte
frontend_connections_total Total frontend connections count
frontend_current_sessions Current active frontend sessions count
frontend_denied_connections_total Total frontend denied connections count
frontend_denied_sessions_total Total frontend denied sessions count
frontend_intercepted_requests_total Total frontend intercepted requests count
frontend_internal_errors_total Total frontend internal errors count
frontend_limit_session_rate Frontend session rate limit count
frontend_limit_sessions Frontend session limit count
frontend_max_sessions Maximum frontend sessions count
frontend_request_errors_total Total frontend request errors count
frontend_requests_denied_total Total frontend requests denied count
frontend_responses_denied_total Total frontend responses denied count
frontend_sessions_total Total frontend sessions count
server_bytes_in_total Total server bytes in byte
server_bytes_out_total Total server bytes out byte
server_response_errors_total Total server response errors count
server_response_time_average_seconds Average server response time in seconds seconds
server_responses_denied_total Total server responses denied count
server_retry_warnings_total Total server retry warnings count
server_safe_idle_connections_current Current safe idle server connections count
server_server_aborts_total Total server server aborts count
server_sessions_total Total server sessions count
server_used_connections_current Current used server connections count
server_uweight Server non-weight count
server_weight Server weight count

For more Metrics explanations, refer to the Haproxy official documentation.

Feedback

Is this page helpful? ×