HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. It is written in C and has a reputation for being fast and efficient.

Prerequisites

  1. Add the following to the file path /etc/haproxy/haproxy.cfg :
listen stats
    bind *:9000
    mode http
    stats enable 
    stats hide-version 
    stats show-node
    stats realm Haproxy\ Statistics 
    stats uri /haproxy_stats
 
  1. For Virtual Machines, install the Linux Agent.

Configuring the credentials

Configure the credentials in the directory /opt/opsramp/agent/conf/app.d/creds.yaml

haproxy:
- name: haproxy
  user: <username>
  pwd: <Password>
  encoding-type: plain
  labels:
    key1: val1
    key2: val2

Configuring the application

Virtual machine

Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-detection.yaml

- name: haproxy
  instance-checks:
    service-check:
      - haproxy
    port-check:
      - 9000
    uri-check:
      - "haproxy_stats"

Docker environment

Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-container-detection.yaml

- name: haproxy
  container-checks:
    image-check:
      - haproxy
    port-check:
      - 9000

Kubernetes environment

Configure the application in config.yaml

- name: haproxy
  container-checks:
    image-check:
      - haproxy
    port-check:
      - 9000

Validate

Go to Resources under the Infrastructure tab to check if your resources are onboarded and the metrics are collected.

Metrics

OpsRamp MetricMetric Display NameUnitDescription
haproxy_statusStatusStatusChecks the status of the backend servers (UP/DOWN)
haproxy_requests_queueQueued RequestsrequestsNumber of requests in the server queue
haproxy_session_currentSessions ActivesessionsCurrent number of concurrent connections
haproxy_session_rateSessionssessions / secondNumber of sessions per second
haproxy_mbytes_rate_inData ReceivedMB / secondThe rate at which the data is received per server in MB
haproxy_mbytes_rate_outData SentMB / secondThe rate at which the data is sent per server in MB
haproxy_denied_rate_reqDenied Requestsdenied req / secondThe rate of denied requests
haproxy_denied_rate_respDenied Responsesdenied resp / secondThe rate of denied responses
haproxy_errors_rate_reqRequest Errorsreq errors / secondThe rate of request errors
haproxy_errors_rate_connConnection Errorsconn errors / secondThe rate of connection errors
haproxy_errors_rate_respResponse Errorsresp errors / secondThe rate of response errors
haproxy_warning_rate_retrWarn Retrieswarning retries / secondThe rate of retries (warning)
haproxy_warning_rate_redisWarn Redis patcheswarning redispatches / secondThe rate of dispatches (warning)
haproxy_requests_rateRequestsrequests / secondRate of received HTTP requests
haproxy_lastchk_timeLast Health Check TimemillisecondssTime taken to finish last health check
haproxy_servers_activeActive Serversactive serversNumber of current active servers (backend). Validates against total active servers
haproxy_servers_backupBackup Serversbackup serversNumber of current backup servers (backend). Validates against total backup servers
haproxy_http_errors_1xx1xx HTTP ErrorserrorsNumber of http error responses with 1xx code
haproxy_http_errors_2xx2xx HTTP ErrorserrorsNumber of http error responses with 2xx code
haproxy_http_errors_3xx3xx HTTP ErrorserrorsNumber of http error responses with 3xx code
haproxy_http_errors_4xx4xx HTTP ErrorserrorsNumber of http error responses with 4xx code
haproxy_http_errors_5xx5xx HTTP ErrorserrorsNumber of http error responses with 5xx code