Docs » Integrations Guide » Use the Smart Agent » Monitors » haproxy

haproxy 🔗

Monitor Type: haproxy (Source)

Accepts Endpoints: Yes

Multiple Instances Allowed: Yes

Overview 🔗

This monitor scrapes HAProxy statistics (i.e. metrics) from a configured HTTP endpoint or UNIX socket. It requires HAProxy 1.8+ and supports scraping metrics for HAProxy running in multi-process mode. In multi-process mode, HAProxy must be configured to enable stats on different URLs/socket paths for the processes and for each URL/path a monitor instance needs to be defined and configured.

HTTP Endpoint Config 🔗

HAProxy stats must be enabled as described here. Define the HAProxy monitor in the agent configuration file and provide the csv export URL where HAProxy stats are served in CSV format. This monitor supports basic HTTP authentication. Simply provide the username and password. In multi-process mode, declare and configure monitors for each stats HTTP endpoint. Below below is an example showing stats enable on 2 URLs.

...
monitors:
  - type: haproxy
    url: "http://localhost:8404/stats?stats;csv"
    username: "your username here"
    password: "your password here"
  - type: haproxy
    url: "http://localhost:6000/stats?stats;csv"
...

Note: Only stats pertaining to the configured proxies (i.e. listeners, frontends, backends, and servers) are available from the HTTP url. HAProxy process level stats given by command show info are not available. The show info stats can only be scraped from a UNIX socket.

UNIX Socket Config 🔗

The location of the HAProxy socket file is defined in the HAProxy config file. For example:

global
    daemon
    stats socket /var/run/haproxy.sock
    stats timeout 2m

For the above location of the socket file, configure the monitor URL as shown below:

...
monitors:
  - type: haproxy
    url: "unix:///var/run/haproxy.sock"
...

Note: The agent process needs read/write permissions to the HAProxy socket file.

Configuration 🔗

To activate this monitor in the Smart Agent, add the following to your agent config:

monitors:  # All monitor config goes under this key
 - type: haproxy
   ...  # Additional config

For a list of monitor options that are common to all monitors, see Common Configuration.

Config option Required Type Description
host no string The host/ip address of the HAProxy instance. This is used to construct the url option if not provided.
port no integer The port of the HAProxy instance's stats endpoint (if using HTTP). This is used to construct the url option if not provided. (default: 0)
path no string The path to HAProxy stats. The default is stats?stats;csv. This is used to construct the url option if not provided. (default: stats?stats;csv)
useHTTPS no bool Whether to connect on HTTPS or HTTP. If you want to use a UNIX socket, then specify the url config option with the format unix://... and omit host, port and useHTTPS. (default: false)
url no string URL on which to scrape HAProxy. Scheme http:// for http-type and unix:// socket-type urls. If this is not provided, it will be derive from the host, port, path, and useHTTPS options.
username no string Basic Auth username to use on each request, if any.
password no string Basic Auth password to use on each request, if any.
sslVerify no bool Flag that enables SSL certificate verification for the scrape URL. (default: true)
timeout no int64 Timeout for trying to get stats from HAProxy. This should be a duration string that is accepted by https://golang.org/pkg/time/#ParseDuration (default: 5s)
proxies no list of strings A list of the pxname(s) and svname(s) to monitor (e.g. ["http-in", "server1", "backend"]). If empty then metrics for all proxies will be reported.

Metrics 🔗

These are the metrics available for this monitor. Metrics that are categorized as container/host (default) are in bold and italics in the list below.

  • haproxy_active_servers (gauge)
    Number of active servers (backend), server is active (server). Values reported for backends and servers.
  • haproxy_backup_servers (gauge)
    Number of backup servers (backend), server is backup (server). Values reported for backends and servers.
  • haproxy_bytes_in (cumulative)
    Total number of incoming bytes. Values reported for listeners, frontends, backends, and servers.
  • haproxy_bytes_out (cumulative)
    Total number of outgoing bytes. Values reported for listeners, frontends, backends, and servers.
  • haproxy_check_duration (gauge)
    Time in ms took to finish last health check. Values reported for servers.
  • haproxy_client_aborts (cumulative)
    Number of data transfers aborted by the client. Values reported for backends and servers.
  • haproxy_compress_bits_per_second_in (cumulative)
    Corresponds to the HAProxy process CompressBpsIn value given by the show info command issued over UNIX socket.
  • haproxy_compress_bits_per_second_out (cumulative)
    Corresponds to the HAProxy process CompressBpsOut value given by the show info command issued over UNIX socket.
  • haproxy_compress_bypass (cumulative)
    Number of bytes that bypassed the HTTP compressor (CPU/BW limit). Values reported for frontends and backends.
  • haproxy_compress_in (cumulative)
    Number of HTTP response bytes fed to the compressor. Values reported for frontends and backends.
  • haproxy_compress_out (cumulative)
    Number of HTTP response bytes emitted by the compressor. Values reported for frontends and backends.
  • haproxy_compress_responses (cumulative)
    Number of HTTP responses that were compressed. Values reported for frontends and backends.
  • haproxy_connection_rate (gauge)
    Number of connections over the last elapsed second. Values reported for frontends.
  • haproxy_connection_rate_all (gauge)
    Corresponds to the HAProxy process ConnRate value given by the show info command issued over UNIX socket.
  • haproxy_connection_rate_max (gauge)
    Highest known conn_rate. Values reported for frontends.
  • haproxy_connection_total (cumulative)
    Cumulative number of connections. Values reported for frontends.
  • haproxy_connections (cumulative)
    Corresponds to the HAProxy process CumConns value given by the show info command issued over UNIX socket. Cumulative number of connections.
  • haproxy_current_connections (gauge)
    Corresponds to the HAProxy process CurrConns value given by the show info command issued over UNIX socket.
  • haproxy_current_ssl_connections (gauge)
    Corresponds to the HAProxy process CurrSslConns value given by the show info command issued over UNIX socket.
  • haproxy_denied_request (cumulative)
    Number of requests denied because of security concerns. For tcp this is because of a matched tcp-request content rule. For http this is because of a matched http-request or tarpit rule. Values reported for listeners, frontends, and backends.
  • haproxy_denied_response (cumulative)
    Number of responses denied because of security concerns. For http this is because of a matched http-request rule, or “option checkcache”. Values reported for listeners, frontends, backends, and servers.
  • haproxy_denied_tcp_connections (gauge)
    Requests denied by “tcp-request connection” rules. Values reported for listeners and frontends.
  • haproxy_denied_tcp_sessions (gauge)
    Requests denied by “tcp-request session” rules. Values reported for listeners and frontends.
  • haproxy_downtime (cumulative)
    Total downtime (in seconds). The value for the backend is the downtime for the whole backend, not the sum of the server downtime. Values reported for backends and servers.
  • haproxy_error_connections (cumulative)
    Number of requests that encountered an error trying to connect to a backend server. The backend stat is the sum of the stat for all servers of that backend, plus any connection errors not associated with a particular server (such as the backend having no active servers). Values reported for backends and servers.
  • haproxy_error_request (cumulative)
    Number of request errors. Some of the possible causes are: early termination from the client, before the request has been sent, read error from the client, client timeout, client closed connection, various bad requests from the client, request was tarpitted. Values reported for listeners and frontends.
  • haproxy_error_response (cumulative)
    Number of response errors. haproxy_server_aborts will be counted here also. Some other errors are: write error on the client socket (won’t be counted for the server stat), failure applying filters to the response. Values reported for backends and servers.
  • haproxy_failed_checks (cumulative)
    Number of failed checks. (Only counts checks failed when the server is up.). Values reported for servers.
  • haproxy_idle_percent (gauge)
    Corresponds to the HAProxy process Idle_pct value given by the show info command issued over UNIX socket. Ratio of system polling time versus total time.
  • haproxy_intercepted_requests (gauge)
    Cumulative number of intercepted requests (monitor, stats). Values reported for frontends and backends.
  • haproxy_last_session (gauge)
    Number of seconds since last session assigned to server/backend. Values reported for backends and servers.
  • haproxy_max_connection_rate (gauge)
    Corresponds to the HAProxy process MaxConnRate value given by the show info command issued over UNIX socket.
  • haproxy_max_connections (gauge)
    Corresponds to the HAProxy process MaxConn value given by the show info command issued over UNIX socket.
  • haproxy_max_pipes (gauge)
    Corresponds to the HAProxy process MaxPipes value given by the show info command issued over UNIX socket.
  • haproxy_max_session_rate (gauge)
    Corresponds to the HAProxy process MaxSessRate value given by the show info command issued over UNIX socket.
  • haproxy_max_ssl_connections (gauge)
    Corresponds to the HAProxy process MaxSslConns value given by the show info command issued over UNIX socket.
  • haproxy_pipes_free (gauge)
    Corresponds to the HAProxy process PipesFree value given by the show info command issued over UNIX socket.
  • haproxy_pipes_used (gauge)
    Corresponds to the HAProxy process PipesUsed value given by the show info command issued over UNIX socket.
  • haproxy_queue_current (gauge)
    Number of current queued requests. For the backend this reports the number queued without a server assigned. Values reported for backends and servers.
  • haproxy_queue_limit (gauge)
    Configured maxqueue for the server, or nothing in the value is 0 (default, meaning no limit). Values reported for servers.
  • haproxy_queue_max (gauge)
    The max value of qcur. Values reported for backends and servers.
  • haproxy_queue_time_average (gauge)
    The average queue time in ms over the 1024 last requests. Values reported for backends and servers.
  • haproxy_redispatched (cumulative)
    Number of times a request was redispatched to another server. The server value counts the number of times that server was switched away from. Values reported for backends and servers.
  • haproxy_request_rate (gauge)
    HTTP requests per second over last elapsed second. Values reported for frontends.
  • haproxy_request_rate_max (gauge)
    Max number of HTTP requests per second observed. Values reported for frontends.
  • haproxy_request_total (cumulative)
    Total number of HTTP requests received. Values reported for frontends and backends.
  • haproxy_requests (cumulative)
    Corresponds to the HAProxy process CumReq value given by the show info command issued over UNIX socket.
  • haproxy_response_1xx (cumulative)
    HTTP responses with 1xx code. Values reported for frontends, backends, and servers.
  • haproxy_response_2xx (cumulative)
    HTTP responses with 2xx code. Values reported for frontends, backends, and servers.
  • haproxy_response_3xx (cumulative)
    HTTP responses with 3xx code. Values reported for frontends, backends, and servers.
  • haproxy_response_4xx (cumulative)
    HTTP responses with 4xx code. Values reported for frontends, backends, and servers.
  • haproxy_response_5xx (cumulative)
    HTTP responses with 5xx code. Values reported for frontends, backends, and servers.
  • haproxy_response_other (cumulative)
    HTTP responses with other codes (protocol error). Values reported for frontends, backends, and servers.
  • haproxy_response_time_average (gauge)
    The average response time in ms over the 1024 last requests (0 for TCP). Values reported for backends and servers.
  • haproxy_retries (cumulative)
    Number of times a connection to a server was retried. Values reported for backends and servers.
  • haproxy_run_queue (gauge)
    Corresponds to the HAProxy process Run_queue value given by the show info command issued over UNIX socket.
  • haproxy_server_aborts (cumulative)
    Number of data transfers aborted by the server (inc. in eresp). Values reported for backends and servers.
  • haproxy_server_selected_total (cumulative)
    Total number of times a server was selected, either for new sessions, or when re-dispatching. The server counter is the number of times that server was selected. Values reported for backends and servers.
  • haproxy_session_current (gauge)
    Number current sessions. Values reported for listeners, frontends, backends, and servers.
  • haproxy_session_limit (gauge)
    The maximum number of connections allowed, configured with maxconn. Values reported for listeners, frontends, backends, and servers.
  • haproxy_session_max (gauge)
    The max value of scur. Values reported for listeners, frontends, backends, and servers.
  • haproxy_session_rate (gauge)
    Number of sessions per second over last elapsed second. Values reported for frontends, backends, and servers.
  • haproxy_session_rate_all (gauge)
    Corresponds to the HAProxy process SessRate value given by the show info command issued over UNIX socket.
  • haproxy_session_rate_limit (gauge)
    Configured limit on new sessions per second. Values reported for frontends.
  • haproxy_session_rate_max (gauge)
    Max number of new sessions per second. Values reported for frontends, backends, and servers.
  • haproxy_session_time_average (gauge)
    The average total session time in ms over the 1024 last requests. Values reported for backends and servers.
  • haproxy_session_total (cumulative)
    The cumulative number of sessions. Values reported for listeners, frontends, backends, and servers.
  • haproxy_ssl_backend_key_rate (gauge)
    Corresponds to the HAProxy process SslBackendKeyRate value given by the show info command issued over UNIX socket.
  • haproxy_ssl_cache_lookups (cumulative)
    Corresponds to the HAProxy process SslCacheLookups value given by the show info command issued over UNIX socket.
  • haproxy_ssl_cache_misses (cumulative)
    Corresponds to the HAProxy process SslCacheMisses value given by the show info command issued over UNIX socket.
  • haproxy_ssl_connections (cumulative)
    Corresponds to the HAProxy process CumSslConns value given by the show info command issued over UNIX socket.
  • haproxy_ssl_frontend_key_rate (gauge)
    Corresponds to the HAProxy process SslFrontendKeyRate value given by the show info command issued over UNIX socket.
  • haproxy_ssl_rate (gauge)
    Corresponds to the HAProxy process SslRate value given by the show info command issued over UNIX socket.
  • haproxy_status (gauge)
    HAProxy status values derived from the status stat. Status stat values UP, UP 1/3, UP 2/3, OPEN and no check are assigned 1. Values DOWN, DOWN 1/2, NOLB and MAINT are assigned 0. Values reported for listeners, frontends, backends and servers.
  • haproxy_tasks (gauge)
    Corresponds to the HAProxy process Tasks value given by the show info command issued over UNIX socket.
  • haproxy_throttle (gauge)
    Current throttle percentage for the server, when slowstart is active, or no value if not in slowstart. Values reported for servers.
  • haproxy_uptime_seconds (cumulative)
    Corresponds to the HAProxy process Uptime_sec value given by the show info command issued over UNIX socket.
  • haproxy_zlib_memory_usage (gauge)
    Corresponds to the HAProxy process ZlibMemUsage value given by the show info command issued over UNIX socket.

Non-default metrics (version 4.7.0+) 🔗

To emit metrics that are not default, you can add those metrics in the generic monitor-level extraMetrics config option. Metrics that are derived from specific configuration options that do not appear in the above list of metrics do not need to be added to extraMetrics.

To see a list of metrics that will be emitted you can run agent-status monitors after configuring this monitor in a running agent instance.

Dimensions 🔗

The following dimensions may occur on metrics emitted by this monitor. Some dimensions may be specific to certain metrics.

Name Description
process_id A number assigned to an HAProxy process instance (1 for first instance, 2 for second, ...).
proxy_name HAProxy configured proxy name. Possible values for listeners, frontends, backends, and servers.
server_id Server id (unique inside a proxy)
service_name HAProxy configured service name. Possible values are FRONTEND for frontend, BACKEND for backend, configured name for server/listener.
type Proxy type id (0=frontend, 1=backend, 2=server, 3=socket/listener).
unique_proxy_id A unique proxy id