Fortinet Document Library

Version:


Table of Contents

User Guide

21.4.0
Copy Link

HAProxy

The HAProxy plugin allows you to monitor a number of metrics to ensure that HAProxy is successfully load balancing and serving requests. HAProxy provides two methods to monitor its performance:

  • Via the Stats page

  • Via a Unix socket

Stats page

The most common way to collect HAProxy metrics is via the stats page. To allow the Agent to access HAProxy metrics via the stats page, enable it by adding the following to the bottom of the /etc/haproxy/haproxy.cfg file.

listen stats
bind :8080
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /haproxy_stats  # Stats URI
stats auth username:password  # Authentication credentials

Note: Authorization credentials are optional.

user is the only level of permissions required for the Agent. However, admin or operator can be used as well.

After modifying the configuration file, restart HAProxy. After restarting the HAProxy, make sure that you can access your HAProxy's stats page.

Agent configuration

The Agent must also be configured to collect metrics from the HAProxy stats page. To do this, add the following to your Agent configuration file.

[haproxy]
stats_http_host = localhost
stats_http_port = 8080
stats_http_path = /haproxy_stats
stats_http_user = username
stats_http_password = password

Authorization credentials are only required if they are used in the HAProxy configuration file.

Unix socket

Another method to enable metric collection is via a Unix socket. Your HAProxy configuration file will need to have stats enabled. To enable stats, add the following to the bottom of the /etc/haproxy/haproxy.cfg file. 

HAProxy configuration

global
stats socket /var/run/haproxy.sock mode 666 level user
stats timeout 2m
listen admin
bind *:8080
stats enable

user is the only level of permissions required for the Agent. However, admin or operator can be used as well.

Agent configuration

The Agent can collect metrics via the HAProxy socket. By default, the Agent connects to /var/run/haproxy.sock. Optionally, if you have customized this location in your installation, you can let us know in the Agent config file using the socket_cfg_file variable.

[haproxy]
socket_cfg_file =/var/run/haproxy.sock

Control Panel Configuration

Like other application monitoring, HAProxy monitoring is added to a server via the Monitoring Catalog. If you don't see HAProxy as a discovered resource, you may need to rebuild your Agent metadata. You can read about that here.

Once HAProxy is added, you can begin monitoring any of the below metrics.

Metric

Unit

Bytes In

bytes/sec

Bytes Out

bytes/sec

Queued requests

requests

Sessions

sessions

Request errors

errors

Response errors

errors

Active servers

servers

Backup servers

servers                                          

Connection Errors                       

errors

1xx's

requests

2xx's

requests

2xx's

requests

If you have any additional questions, please contact our support team.

HAProxy

The HAProxy plugin allows you to monitor a number of metrics to ensure that HAProxy is successfully load balancing and serving requests. HAProxy provides two methods to monitor its performance:

  • Via the Stats page

  • Via a Unix socket

Stats page

The most common way to collect HAProxy metrics is via the stats page. To allow the Agent to access HAProxy metrics via the stats page, enable it by adding the following to the bottom of the /etc/haproxy/haproxy.cfg file.

listen stats
bind :8080
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /haproxy_stats  # Stats URI
stats auth username:password  # Authentication credentials

Note: Authorization credentials are optional.

user is the only level of permissions required for the Agent. However, admin or operator can be used as well.

After modifying the configuration file, restart HAProxy. After restarting the HAProxy, make sure that you can access your HAProxy's stats page.

Agent configuration

The Agent must also be configured to collect metrics from the HAProxy stats page. To do this, add the following to your Agent configuration file.

[haproxy]
stats_http_host = localhost
stats_http_port = 8080
stats_http_path = /haproxy_stats
stats_http_user = username
stats_http_password = password

Authorization credentials are only required if they are used in the HAProxy configuration file.

Unix socket

Another method to enable metric collection is via a Unix socket. Your HAProxy configuration file will need to have stats enabled. To enable stats, add the following to the bottom of the /etc/haproxy/haproxy.cfg file. 

HAProxy configuration

global
stats socket /var/run/haproxy.sock mode 666 level user
stats timeout 2m
listen admin
bind *:8080
stats enable

user is the only level of permissions required for the Agent. However, admin or operator can be used as well.

Agent configuration

The Agent can collect metrics via the HAProxy socket. By default, the Agent connects to /var/run/haproxy.sock. Optionally, if you have customized this location in your installation, you can let us know in the Agent config file using the socket_cfg_file variable.

[haproxy]
socket_cfg_file =/var/run/haproxy.sock

Control Panel Configuration

Like other application monitoring, HAProxy monitoring is added to a server via the Monitoring Catalog. If you don't see HAProxy as a discovered resource, you may need to rebuild your Agent metadata. You can read about that here.

Once HAProxy is added, you can begin monitoring any of the below metrics.

Metric

Unit

Bytes In

bytes/sec

Bytes Out

bytes/sec

Queued requests

requests

Sessions

sessions

Request errors

errors

Response errors

errors

Active servers

servers

Backup servers

servers                                          

Connection Errors                       

errors

1xx's

requests

2xx's

requests

2xx's

requests

If you have any additional questions, please contact our support team.