The dashboard package you used to install the dashboard UI also includes a Lua module that returns HAProxy statistics. It allows the Real-Time Dashboard to display live data.

Prerequisites

  • HAProxy Enterprise version >= 1.7. Use 1.8 or newer if using the Stick Table Explorer.

  • Dashboard module version >= 1.0

Enable metrics for a single instance

  1. In the configuration file (see below), edit the OPTIONS line so that it reads the dashboard-module.cfg file when HAProxy service starts, as follows according to your operating system:

    • On Debian/Ubuntu, edit the file /etc/default/hapee-2.2-lb.

    • On Redhat/CentOS, edit /etc/sysconfig/hapee-2.2-lb.

      OPTIONS="-f /etc/hapee-2.2/dashboard-module.cfg"
  2. The dashboard-module.cfg file starts a new listener at port 9022 that exposes metrics data. This data comes from an applet defined in the Dashboard Lua module located in /opt/hapee-2.2/dashboard/dashboard-module. Restart the HAProxy service for the change to take effect:

    $ sudo systemctl restart hapee-2.2-lb
  3. Click the Settings button to display the Settings window.

  4. Set Data Source to Real Time Dashboard Module.

  5. Set Data Source Mode to Single Node and close the window.

  6. Open the Real-Time Dashboard in your browser and change the URL in the header bar to the address of your HAProxy instance. The port defaults to 9022, so you do not need to set it here.

  7. Click the Start button to complete setup.

Enable metrics for multiple instances

Optionally, you can connect to data feeds from multiple HAProxy instances running on different servers:

  1. On each HAProxy server, install the Real-Time Dashboard.

  2. Edit the configuration file to enable metrics. See Enable metrics for a single instance.

  3. Choose one server to act as the "aggregation master" instance. On that server, update the file /opt/hapee-2.2/dashboard/dashboard-module/dashboard-config.lua. Initially, it contains the following, empty configuration:

    conf = {
        cluster = {
            nodes = nil,
            master = false
        }
    }
  4. Add the IP address and port of each HAProxy instance to the nodes property. Also, set the master property to true:

    conf = {
        cluster = {
            nodes = {
                "192.168.50.25:9022",
                "192.168.50.26:9022",
                "192.168.50.27:9022",
            },
            master = true
        }
    }
  5. Restart the HAProxy service:

    $ sudo systemctl restart hapee-2.2-lb
  6. Open the Real-Time Dashboard in your browser, then click the Settings button to display the Settings window.

  7. Set Data Source to Real Time Dashboard Module.

  8. Set Data Source Mode to Cluster Aggregation and close the window.

  9. Click the Start button to complete setup.

Enable metrics for multiple processes

  1. Edit the HAProxy configuration to start multiple processes using the nbproc directive in the global section. Set the value to the number of processes to create, as in the following example:

    global
        nbproc 2
  2. Add a bind-process directive to one or several frontend or listen sections to associate them with a specific process. For example:

    frontend website
        bind :80
        bind-process 1
        default_backend webservers
    
    frontend api
        bind 8080
        bind-process 2
        default_backend apiservers
  3. Install the Real-Time Dashboard.

  4. Edit the configuration file to enable metrics. See Enable metrics for a single instance.

  5. Update the file Real-Time Dashboard configuration file /etc/hapee-2.2/dashboard-module.cfg so that its listen section has a bind line for each process:

    listen dashboard
        bind *:9022 process 1
        bind *:9122 process 2
  6. Update the file /opt/hapee-2.2/dashboard/dashboard-module/dashboard-config.lua. Initially, it contains the following, empty configuration:

    conf = {
        cluster = {
            nodes = nil,
            master = false
        }
    }
  7. Add the IP address and port of each HAProxy process to the nodes property. Also, set the master property to true:

    conf = {
        cluster = {
            nodes = {
                "192.168.50.25:9022",
                "192.168.50.25:9122",
            },
            master = true
        }
    }
  8. Restart the HAProxy service:

    $ sudo systemctl restart hapee-2.2-lb
  9. Open the Real-Time Dashboard in your browser and click the Settings button to display the Settings window.

  10. Set Data Source to Real Time Dashboard Module.

  11. Set Data Source Mode to Cluster Aggregation and close the window.

  12. Click the Start button to complete setup.

Set HTTP basic authentication

When you enable HTTP basic authentication in the file dashboard-module.cfg, the Real-Time Dashboard Lua module's API is restricted to certain users. By default, the configuration defines a user named "dashboard" with the password "test". Change the username and password, and update the Real-Time Dashboard's settings to match.

  1. Install the whois package with apt or yum to get the mkpasswd utility:

    $ sudo apt install whois
  2. se mkpasswd to create a SHA-2 password:

    $ mkpasswd -m SHA-256
  3. Edit the configuration file /etc/hapee-2.2/dashboard-module.cfg to change the dashboard_users userlist section so that it contains one user line to define a username and encrypted password.

  4. Add the password to the user line, and restart the HAProxy service:

    $ sudo systemctl restart hapee-2.2-lb
  5. Open the Real-Time Dashboard in your browser and click the Settings button to display the Settings window. Set the Username and Password values to match.

Enable HTTPS between the Dashboard UI and HAProxy

The UI fetches metrics from HAProxy. In order to encrypt this communication, you must enable HTTPS.

  1. Obtain a valid TLS certificate for the node where you are running HAProxy Enterprise. This is the aggregation master node when you run multiple instances of HAProxy Enterprise.

  2. Save it to /etc/hapee-2.2/certs.

  3. Edit the file /etc/hapee-2.2/dashboard-module.cfg to remove the following line from the listen dashboard section:

    listen dashboard
        # ...
        bind *:9022
  4. Replace it with the following line, changing ssl.pem to be name of your TLS certificate:

    listen dashboard
        # ...
        bind *:9023 ssl crt /etc/hapee-2.0/certs/ssl.pem
  5. Restart the HAProxy service:

    $ sudo systemctl restart hapee-2.2-lb
  6. Open the Real-Time Dashboard in your browser and change the address in the header bar to be the hostname that matches the TLS certificate's CN value. Click the padlock icon to turn it green.

  7. Click the Start button to complete setup.

Note

If you use a self-signed certificate, you must either import it into your workstation's trusted certificate store, or accept it as an untrusted certificate in your browser. To do so, open a new tab and enter the URL to the API, such as https://lb1.test.com:9023/dashboard/info, and accept the certificate.