HAProxy (Proxy, ReverseProxy: Frontend, Backend, Servers)

Dynamic Dashboard for HAProxy @by Florian-Romel CHIORĂSCU

HAProxy (Proxy, ReverseProxy: Frontend, Backend, Servers) screenshot 1
HAProxy (Proxy, ReverseProxy: Frontend, Backend, Servers) screenshot 2

This dashboard displays the detailed metrics for Frontend/ Backend/ Server:

  • HTTP codes (2xx, 3xx, 4xx, 5xx, other);
  • Error 4xx, 5xx;
  • Throughput;
  • IN/OUT Bytes;
  • Availability;
  • Connections Utilization %;
  • Etc…

For collecting the HAProxy metrics from server it requires to install/configure the haproxy_exporter from prometheus repository:

Prometheus configuration: /opt/prometheus/prometheus.yml

    - job_name: proxy01
      static_configs:
        - targets: ['192.168.1.10:9101']
          labels:
            env: prod
            alias: proxy01

haproxy_exporter configuration: /usr/lib/systemd/system/haproxy_exporter.service

    [Unit]
    Description=Prometheus HAProxy Exporter
    After=network.target
    
    [Service]
    Type=simple
    User=haproxy
    Group=haproxy
    
    ExecStart=/opt/haproxy_exporter/haproxy_exporter --haproxy.scrape-uri=unix:/var/lib/haproxy/stats --web.listen-address 0.0.0.0:9101 --log.level=info
    ExecReload=/bin/kill -HUP $MAINPID
    TimeoutStopSec=10s
    SendSIGKILL=no

    SyslogIdentifier=prometheus_haproxy_exporter
    Restart=always
    
    [Install]
    WantedBy=multi-user.target

You need to have the stats option configured in your global section of /etc/haproxy/haproxy.cfg file:

    global
      #--------------------#
      # logs configuration #
      #--------------------#
      log 127.0.0.1 local0 debug
      log 127.0.0.1 local1 notice
      #----------------------------#
      # turn on stats unix sockets #
      #----------------------------#
      stats socket /var/lib/haproxy/stats user haproxy group haproxy mode 660 level user
      stats timeout 30s
      #-----------------------------------------------------#
      # performance configuration                           #
      # maximum per-process number of concurrent connection #
      #-----------------------------------------------------#
      maxconn 40000
      tune.ssl.default-dh-param 2048

Selinux and permissions for HAProxy:

      $ ls -ltrha  /var/lib/haproxy/stats
         srw-rw----. 1 haproxy haproxy 0 Jan 17 15:37 /var/lib/haproxy/stats
      $ semanage permissive -a haproxy_t
      $ ps -eZ | grep haproxy_t
Revisions
RevisionDescriptionCreated
HAProxy

HAProxy

by Grafana Labs
Grafana Labs solution

Easily monitor HAProxy, a free, fast, and reliable reverse-proxy, with Grafana Cloud's out-of-the-box monitoring solution.

Learn more

Get this dashboard

Import the dashboard template

or

Download JSON

Datasource
Dependencies