Documentation forAppOptics

HAProxy

Overview

The haproxy plugin is an integration for monitoring HAProxy, a free, fast, and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications.

Setup

This integration is included as part of a SWI collector. The SWI collector bundles several collectors into one integrated binary.

The haproxy plugin is included with the SolarWinds Snap Agent by default. This section describes how to enable the plugin for a Snap Agent instance.

With Snap Agent version 4.5.0 and later, this plugin was upgraded to use the v2 plugins framework. If you are running v1 of the collector, see AppOptics Snap Agent 4.4.0 documentation.

To migrate to the v2 plugins framework, update Snap Agent to the latest version and see Migrate from v1 to v2 appoptics publisher plugins.

Prerequisites

This plugin requires that HAProxy is running, and its statistics endpoint API is available from the host running the plugin. The integration supports a connection using a local or remote Uniform Resource Identifier (URI) or UNIX socket.

This plugin supports HAProxy version 1.4 through 2.4.

You can customize the relevant values in the haproxy configuration file so they apply to your deployment, as shown below

...
global
  ...
  
  stats socket /run/haproxy/haproxy.sock mode 660 level admin

...

listen stats
  bind 127.0.0.1:1936 # default

  stats enable
  stats auth admin:admin
  stats realm HAProxy\ Statistics
  stats show-node
  stats uri /haproxy?stats # default

...

Configuration

To help you get started HAProxy metrics, the agent includes an example v2 task manifest file with a predefined task configuration. This file is located at:

/opt/SolarWinds/Snap/etc/tasks-autoload.d/task-haproxy.yaml.example

When the task configuration is enabled, the Snap Agent automatically loads the plugin when needed.

To enable the task:

  1. Make a copy of the example haproxy v2 task manifest file and name it task-haproxy.yaml.

    sudo cp -p /opt/SolarWinds/Snap/etc/tasks-autoload.d/task-haproxy.yaml.example /opt/SolarWinds/Snap/etc/tasks-autoload.d/taskhaproxy.yaml
  2. (Optional) Edit the task-haproxy.yaml file to match your custom settings.

    For example: 

    ---
    version: 2
    
    schedule:
      type: cron
      interval: "0 * * * * *"
    
    plugins:
    - plugin_name: swi
    
      config:
        haproxy:
          ## List of endpoints to query for stats
    endpoints:
    
          ## mind the hyphen (yaml list marker) below!
    -
    
          ## Setting should correspond to values set in
          ## 'listen stats' section in haproxy.cfg at 'bind', 'mode' and 'stats uri'
          ## and should begin with http:// or https://
          url: "http://127.0.0.1:1936/haproxy?stats;csv"
          ## ... or with unix:// for socket-based connection, as set in haproxy.cfg at 'stats socket'
          # endpoint: "unix:///run/haproxy/haproxy.sock"
    
          ## url may include auth credentials (optional)
          ## Setting should correspond to value set in haproxy.cfg at 'stats auth' (if any), eg:
          # url: "http://admin:admin@127.0.0.1:1936/haproxy?stats;csv"
          ## ... or credentials can be also provided separately
          # username: "username"
          # password: "password"
          ## Timeout for connecting to HAProxy API
          ## Defaults to 5s
          # timeout: "5s"
      publish:
      - plugin_name: publisher-appoptics
    
      metrics:
        - /haproxy/[endpoint]/[pxname]/[svname]/qcur # Current number of connections waiting in the server of backend queue
        - /haproxy/[endpoint]/[pxname]/[svname]/qmax # Highest value of qcur encountered since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/scur # Current number of sessions on the frontend, backend or server
        - /haproxy/[endpoint]/[pxname]/[svname]/smax # Highest value of scur encountered since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/slim # Frontend /listener/server's maxconn, backend's fullconn
        - /haproxy/[endpoint]/[pxname]/[svname]/stot # Total number of sessions since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/bin # Total number of request bytes since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/bout # Total number of response bytes since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/dreq # Total number of denied requests since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/dresp # Total number of denied responses since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/ereq # Total number of invalid requests since process started
        - /haproxy/[endpoint]/[pxname]/[svname]/econ # Total number of failed connections to server since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/eresp # Total number of invalid responses since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/wretr # Total number of server connection retries since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/wredis # Total number of server redispatches due to connection failures since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/status # Frontend/listen status: OPEN/WAITING/FULL/STOP; backend: UP/DOWN; server: last check status
        - /haproxy/[endpoint]/[pxname]/[svname]/weight # Server's effective weight, or sum of active servers' effective weights for a backend
        - /haproxy/[endpoint]/[pxname]/[svname]/act # Total number of active UP servers with a non-zero weight
        - /haproxy/[endpoint]/[pxname]/[svname]/bck # Total number of backup UP servers with a non-zero weight
        - /haproxy/[endpoint]/[pxname]/[svname]/chkfail # Total number of failed individual health checks per server/backend, since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/chkdown # Total number of failed checks causing UP to DOWN server transitions, per server/backend, since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/lastchg # How long ago the last server state changed, in seconds
        - /haproxy/[endpoint]/[pxname]/[svname]/downtime # Total time spent in DOWN state, for server or backend
        - /haproxy/[endpoint]/[pxname]/[svname]/qlimit # Limit on the number of connections in queue, for servers only (maxqueue argument)
        - /haproxy/[endpoint]/[pxname]/[svname]/pid # Relative worker process number (1..nbproc)
        - /haproxy/[endpoint]/[pxname]/[svname]/iid # Frontend or Backend numeric identifier ('id' setting)
        - /haproxy/[endpoint]/[pxname]/[svname]/sid # Server numeric identifier ('id' setting)
        - /haproxy/[endpoint]/[pxname]/[svname]/throttle # Throttling ratio applied to a server's maxconn and weight during the slowstart period (0 to 100%)
        - /haproxy/[endpoint]/[pxname]/[svname]/lbtot # Total number of requests routed by load balancing since the worker process started (ignores queue pop and stickiness)
        - /haproxy/[endpoint]/[pxname]/[svname]/tracked # Name of the other server this server tracks for its state
        - /haproxy/[endpoint]/[pxname]/[svname]/type # Type of the object (Listener, Frontend, Backend, Server)
        - /haproxy/[endpoint]/[pxname]/[svname]/rate # Total number of sessions processed by this object over the last second (sessions for listeners/frontends, requests for backends/servers)
        - /haproxy/[endpoint]/[pxname]/[svname]/rate_lim # Limit on the number of sessions accepted in a second (frontend only, 'rate-limit sessions' setting)
        - /haproxy/[endpoint]/[pxname]/[svname]/rate_max # Highest value of 'rate' observed since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/check_status # Status report of the server's latest health check, prefixed with '*' if a check is currently in progress
        - /haproxy/[endpoint]/[pxname]/[svname]/check_code # HTTP /SMTP/LDAP status code reported by the latest server health check
        - /haproxy/[endpoint]/[pxname]/[svname]/check_duration # Total duration of the latest server health check, in milliseconds
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_1xx # Total number of HTTP responses with status 100-199 returned by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_2xx # Total number of HTTP responses with status 200-299 returned by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_3xx # Total number of HTTP responses with status 300-399 returned by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_4xx # Total number of HTTP responses with status 400-499 returned by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_5xx # Total number of HTTP responses with status 500-599 returned by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/hrsp_other # Total number of HTTP responses with status <100, >599 returned by this object since the worker process started (error -1 included)
        - /haproxy/[endpoint]/[pxname]/[svname]/hanafail # Total number of failed checks caused by an 'on-error' directive after an 'observe' condition matched
        - /haproxy/[endpoint]/[pxname]/[svname]/req_rate # Number of HTTP requests processed over the last second on this object
        - /haproxy/[endpoint]/[pxname]/[svname]/req_rate_max # Highest value of 'req_rate' observed since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/req_tot # Total number of HTTP requests processed by this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/cli_abrt # Total number of requests or connections aborted by the client since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/srv_abrt # Total number of requests or connections aborted by the server since the worker process started
    
        ## since 1.5
        - /haproxy/[endpoint]/[pxname]/[svname]/comp_in # Total number of bytes submitted to the HTTP compressor for this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/comp_out # Total number of bytes emitted by the HTTP compressor for this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/comp_byp # Total number of bytes that bypassed HTTP compression for this object since the worker process started (CPU/memory/bandwidth limitation)
        - /haproxy/[endpoint]/[pxname]/[svname]/comp_rsp # Total number of HTTP responses that were compressed for this object since the worker process started
        - /haproxy/[endpoint]/[pxname]/[svname]/lastsess # How long ago some traffic was seen on this object on this worker process, in seconds
    
        ## since 1.5.19
        - /haproxy/[endpoint]/[pxname]/[svname]/last_chk # Short description of the latest health check report for this server (see also check_desc)
        - /haproxy/[endpoint]/[pxname]/[svname]/last_agt # Short description of the latest agent check report for this server (see also agent_desc)
        - /haproxy/[endpoint]/[pxname]/[svname]/qtime # Time spent in the queue, in milliseconds, averaged over the 1024 last requests (backend/server)
        - /haproxy/[endpoint]/[pxname]/[svname]/ctime # Time spent waiting for a connection to complete, in milliseconds, averaged over the 1024 last requests (backend/server)
        - /haproxy/[endpoint]/[pxname]/[svname]/rtime # Time spent waiting for a server response, in milliseconds, averaged over the 1024 last requests (backend/server)
        - /haproxy/[endpoint]/[pxname]/[svname]/ttime # Total request+response time (request+queue+connect+response+processing), in milliseconds, averaged over the 1024 last requests (backend /server)
        
        ## since 1.7
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_status # Status report of the server's latest agent check, prefixed with '*' if a check is currently in progress
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_code # Status code reported by the latest server agent check
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_duration # Total duration of the latest server agent check, in milliseconds
        # - /haproxy/[endpoint]/[pxname]/[svname]/check_desc # Textual description of the latest health check report for this server
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_desc # Textual description of the latest agent check report for this server
        # - /haproxy/[endpoint]/[pxname]/[svname]/check_rise # Number of successful health checks before declaring a server UP (server 'rise' setting)
        # - /haproxy/[endpoint]/[pxname]/[svname]/check_fall # Number of failed health checks before declaring a server DOWN (server 'fall' setting)
        # - /haproxy/[endpoint]/[pxname]/[svname]/check_health # Current server health check level (0..fall-1=DOWN, fall..rise-1=UP)
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_rise # Number of successful agent checks before declaring a server UP (server 'rise' setting)
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_fall # Number of failed agent checks before declaring a server DOWN (server 'fall' setting)
        # - /haproxy/[endpoint]/[pxname]/[svname]/agent_health # Current server agent check level (0..fall-1=DOWN, fall..rise-1=UP)
        # - /haproxy/[endpoint]/[pxname]/[svname]/addr # Server's address:port, shown only if show-legends is set, or at levels oper/admin for the CLI
        # - /haproxy/[endpoint]/[pxname]/[svname]/cookie # Backend's cookie name or Server's cookie value, shown only if showlegends is set, or at levels oper/admin for the CLI
        # - /haproxy/[endpoint]/[pxname]/[svname]/mode # mode' setting (tcp/http/health/cli)
        # - /haproxy/[endpoint]/[pxname]/[svname]/algo # Backend's load balancing algorithm, shown only if show-legends is set, or at levels oper/admin for the CLI
        # - /haproxy/[endpoint]/[pxname]/[svname]/conn_rate # Number of new connections accepted over the last second on the frontend for this worker process
        # - /haproxy/[endpoint]/[pxname]/[svname]/conn_rate_max # Highest value of 'conn_rate' observed since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/conn_tot # Total number of new connections accepted on this frontend since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/intercepted # Total number of HTTP requests intercepted on the frontend (redirects/stats/services) since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/dcon # Total number of incoming connections blocked on a listener/frontend by a tcp-request connection rule since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/dses # Total number of incoming sessions blocked on a listener/frontend by a tcp-request connection rule since the worker process started
    
        # ## since 1.9
        # - /haproxy/[endpoint]/[pxname]/[svname]/wrew # Total number of failed HTTP header rewrites since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/connect # Total number of outgoing connection attempts on this backend /server since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/reuse # Total number of reused connection on this backend/server since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/cache_lookups # Total number of HTTP requests looked up in the cache on this frontend/backend since the worker process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/cache_hits # Total number of HTTP requests not found in the cache on this frontend/backend since the worker process started
    
        # ## since 2.0
        # - /haproxy/[endpoint]/[pxname]/[svname]/srv_icur # Current number of idle connections available for reuse on this server
        # - /haproxy/[endpoint]/[pxname]/[svname]/src_ilim # Limit on the number of available idle connections on this server (server 'pool_max_conn' directive)
        # - /haproxy/[endpoint]/[pxname]/[svname]/qtime_max # Maximum observed time spent in the queue, in milliseconds (backend /server)
        # - /haproxy/[endpoint]/[pxname]/[svname]/ctime_max # Maximum observed time spent waiting for a connection to complete, in milliseconds (backend/server)
        # - /haproxy/[endpoint]/[pxname]/[svname]/rtime_max # Maximum observed time spent waiting for a server response, in milliseconds (backend/server)
        # - /haproxy/[endpoint]/[pxname]/[svname]/ttime_max # Maximum observed total request+response time (request+queue+connect+response+processing), in milliseconds (backend/server)
    
        # ## since 2.2
        # - /haproxy/[endpoint]/[pxname]/[svname]/eint # Total number of internal errors since process started
        # - /haproxy/[endpoint]/[pxname]/[svname]/idle_conn_cur # Current number of unsafe idle connections
        # - /haproxy/[endpoint]/[pxname]/[svname]/safe_conn_cur # Current number of safe idle connections
        # - /haproxy/[endpoint]/[pxname]/[svname]/used_conn_cur # Current number of connections in use
        # - /haproxy/[endpoint]/[pxname]/[svname]/need_conn_est # Estimated needed number of connections
    
        # ## since 2.3
        # - /haproxy/[endpoint]/[pxname]/[svname]/uweight # Server's user weight, or sum of active servers' user weights for a backend
        # ## ---------------- additional modules ---------------- //
        
        # ## h2 stats (since 2.3)
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_headers_rcvd # Total number of received HEADERS frames
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_data_rcvd # Total number of received DATA frames
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_settings_rcvd # Total number of received SETTINGS frames
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_rst_stream_rcvd # Total number of received RST_STREAM frames
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_goaway_rcvd # Total number of received GOAWAY frames
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_detected_conn_protocol_errors # Total number of connection protocol errors
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_detected_strm_protocol_errors # Total number of stream protocol errors
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_rst_stream_resp # Total number of RST_STREAM sent on detected error
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_goaway_resp # Total number of GOAWAY sent on detected error
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_open_connections # Count of currently open connections
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_backend_open_streams # Count of currently open streams
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_total_connections # Total number of connections
        # - /haproxy/[endpoint]/[pxname]/[svname] /h2_backend_total_streams # Total number of streams
    
        # ## ssl stats (since 2.4)
        # - /haproxy/[endpoint]/[pxname]/[svname]/ssl_sess # Total number of ssl sessions established
        # - /haproxy/[endpoint]/[pxname]/[svname] /ssl_reused_sess # Total number of ssl sessions reused
        # - /haproxy/[endpoint]/[pxname]/[svname] /ssl_failed_handshake # Total number of failed handshake
    
        # ## dns stats (since 2.4)
        # - /haproxy/[endpoint]/[pxname]/[svname]/id # ID
        # - /haproxy/[endpoint]/[pxname]/[svname]/pid # Parent ID
        # - /haproxy/[endpoint]/[pxname]/[svname]/sent # Sent
        # - /haproxy/[endpoint]/[pxname]/[svname]/send_error # Send error
        # - /haproxy/[endpoint]/[pxname]/[svname]/valid # Valid
        # - /haproxy/[endpoint]/[pxname]/[svname]/update # Update
        # - /haproxy/[endpoint]/[pxname]/[svname]/cname # CNAME
        # - /haproxy/[endpoint]/[pxname]/[svname]/cname_error # CNAME error
        # - /haproxy/[endpoint]/[pxname]/[svname]/any_err # Any errors
        # - /haproxy/[endpoint]/[pxname]/[svname]/nx # NX
        # - /haproxy/[endpoint]/[pxname]/[svname]/timeout # Timeout
        # - /haproxy/[endpoint]/[pxname]/[svname]/refused # Refused
        # - /haproxy/[endpoint]/[pxname]/[svname]/other # Other
        # - /haproxy/[endpoint]/[pxname]/[svname]/invalid # Invalid
        # - /haproxy/[endpoint]/[pxname]/[svname]/too_big # Too big
        # - /haproxy/[endpoint]/[pxname]/[svname]/truncated # Truncated
        # - /haproxy/[endpoint]/[pxname]/[svname]/outdated #
    Outdated
  3. Restart the agent.

    sudo service swisnapd restart
  4. Enable the HAProxy plugin in the AppOptics user interface.

    When this procedure is completed successfully, the Docker plugin is available on the Integrations page. Select the HAProxy plugin to open the configuration menu in the user interface and enable the plugin.

    You should see the haproxy metrics reported to your dashboard. If the plugin is not available, see Troubleshooting Linux.

Metrics and tags

Default metric tags

All HAProxy metrics are tagged with hostname. Instead of using this tag, SolarWinds recommends using the @host alias.

Each metric is tagged with endpoint, pxname and svname. The metrics status, check_status, agent_status and mode are mapped to numeric values and tagged with their original text values.

All metrics

All metrics retain their original names as returned from the HAProxy statistic. Each metric is described in the official HAProxy documentation.

You can request each metric using the following format: 

/haproxy/<endpoint>/<pxname>/<svname>/<metric_name>

where the bracketed values contain explicit values or use a wildcard (*). For one or more endpoints, you can use any valid substring of the requested endpoint.

All available metrics are numeric. The metric values for status, check_status, agent_status and mode are mapped to sequential integer values, and tagged to their original text values.

All available metrics are listed in the task configuration file. Type values are adapted from the official documentation and state which type may have a value for given field. These types include L (Listeners), F (Frontends), B (Backends), and S (Servers).

The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.