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

Dashboard

Dynamic Dashboard for HAProxy @by Florian-Romel CHIORĂSCU
Last updated: a month ago

Downloads: 94

  • 2.JPG
    2.JPG
  • 1.JPG
    1.JPG

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:

  • https://github.com/prometheus/haproxy_exporter

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