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"

If the URI check is not provided then by default,haproxy_stats is considered.

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 NameUnit
haproxy_status

Checks the status of the backend servers (UP/DOWN)
StatusStatus
haproxy_requests_queue

Number of requests in the server queue
Queued Requestsrequests
haproxy_session_current

Current number of concurrent connections
Sessions Activesessions
haproxy_session_rate

Number of sessions per second
Sessionssessions / second
haproxy_mbytes_rate_in

The rate at which the data is received per server in MB
Data ReceivedMB / second
haproxy_mbytes_rate_out

The rate at which the data is sent per server in MB
Data SentMB / second
haproxy_denied_rate_req

The rate of denied requests
Denied Requestsdenied req / second
haproxy_denied_rate_resp

The rate of denied responses
Denied Responsesdenied resp / second
haproxy_errors_rate_req

The rate of request errors
Request Errorsreq errors / second
haproxy_errors_rate_conn

The rate of connection errors
Connection Errorsconn errors / second
haproxy_errors_rate_resp

The rate of response errors
Response Errorsresp errors / second
haproxy_warning_rate_retr

The rate of retries (warning)
Warn Retrieswarning retries / second
haproxy_warning_rate_redis

The rate of dispatches (warning)
Warn Redis patcheswarning redispatches / second
haproxy_requests_rate

Rate of received HTTP requests
Requestsrequests / second
haproxy_lastchk_time

Time taken to finish last health check
Last Health Check Timemillisecondss
haproxy_servers_active

Number of current active servers (backend). Validates against total active servers
Active Serversactive servers
haproxy_servers_backup

Number of current backup servers (backend). Validates against total backup servers
Backup Serversbackup servers
haproxy_http_errors_1xx

Number of http error responses with 1xx code
1xx HTTP Errorserrors
haproxy_http_errors_2xx

Number of http error responses with 2xx code
2xx HTTP Errorserrors
haproxy_http_errors_3xx

Number of http error responses with 3xx code
3xx HTTP Errorserrors
haproxy_http_errors_4xx

Number of http error responses with 4xx code
4xx HTTP Errorserrors
haproxy_http_errors_5xx

Number of http error responses with 5xx code
5xx HTTP Errorserrors