Monitoring HAProxy

This article will help you get the Haproxy plugin for sd-agent configured and returning metrics

Installing the haproxy plugin package

Install the haproxy plugin on Debian/Ubuntu:

sudo apt-get install sd-agent-haproxy

Install the haproxy plugin on RHEL/CentOS:

sudo yum install sd-agent-haproxy

Read more about agent plugins.

Configuring the agent to monitor HAProxy

1. Configure /etc/sd-agent/conf.d/haproxy.yaml

init_config:

 instances:
 - url: http://localhost/admin?stats
   #username: xxx
   #password: xxx
   #collect_status_metrics: True
   #collect_status_metrics_by_host: True
  • If your status URL requires authentication uncomment the username and password options, adding your authentication details.
  • Host status metrics can be collected by uncommenting the collect_status_metrics and collect_status_metrics_by_host in the above example. These are set to false by default.

2. Restart the agent

sudo /etc/init.d/sd-agent restart

or

sudo systemctl restart sd-agent

Verifying the configuration
Execute info to verify the configuration with the following:

sudo /etc/init.d/sd-agent info 

or

/usr/share/python/sd-agent/agent.py info

If the agent has been configured correctly you'll see an output such as:

haproxy
-----
  - instance #0 [OK]
  - Collected * metrics

You can also view the metrics returned with the following command:

sudo -u sd-agent /usr/share/python/sd-agent/agent.py check haproxy

Configuring graphs

Click the name of your server from the Devices list in your Server Density account then go to the Metrics tab. Click the + Graph button on the right then choose the haproxy metrics to display the graphs. The metrics will also be available to select when building dashboard graphs.

Screen_Shot_2018-01-18_at_11.46.12.png

Monitored metrics

MetricValues
haproxy.backend.bytes.in_rate

byte / second
Type: float
haproxy.backend.bytes.out_rate

byte / second
Type: float
haproxy.backend.connect.time

millisecond /
Type: float
haproxy.backend.denied.req_rate

request / second
Type: float
haproxy.backend.denied.resp_rate

response / second
Type: float
haproxy.backend.errors.con_rate

error / second
Type: float
haproxy.backend.errors.resp_rate

error / second
Type: float
haproxy.backend.queue.current

request /
Type: float
haproxy.backend.queue.time

millisecond /
Type: float
haproxy.backend.response.1xx

response / second
Type: float
haproxy.backend.response.2xx

response / second
Type: float
haproxy.backend.response.3xx

response / second
Type: float
haproxy.backend.response.4xx

response / second
Type: float
haproxy.backend.response.5xx

response / second
Type: float
haproxy.backend.response.other

response / second
Type: float
haproxy.backend.response.time

millisecond /
Type: float
haproxy.backend.session.current

session /
Type: float
haproxy.backend.session.limit

session /
Type: float
haproxy.backend.session.pct

percent /
Type: float
haproxy.backend.session.rate

connection / second
Type: float
haproxy.backend.session.time

millisecond /
Type: float
haproxy.backend.uptime

Number of seconds since the last UP<->DOWN transition
second / None
Type: float
haproxy.backend.warnings.redis_rate

warning / second
Type: float
haproxy.backend.warnings.retr_rate

warning / second
Type: float
haproxy.backend_hosts

/
Type: int
haproxy.count_per_status

/
Type: int
haproxy.frontend.bytes.in_rate

byte / second
Type: float
haproxy.frontend.bytes.out_rate

byte / second
Type: float
haproxy.frontend.denied.req_rate

request / second
Type: float
haproxy.frontend.denied.resp_rate

response / second
Type: float
haproxy.frontend.errors.req_rate

error / second
Type: float
haproxy.frontend.requests.rate

Number of HTTP requests per second.
request / second
Type: float
haproxy.frontend.response.1xx

response / second
Type: float
haproxy.frontend.response.2xx

response / second
Type: float
haproxy.frontend.response.3xx

response / second
Type: float
haproxy.frontend.response.4xx

response / second
Type: float
haproxy.frontend.response.5xx

response / second
Type: float
haproxy.frontend.response.other

response / second
Type: float
haproxy.frontend.session.current

session /
Type: float
haproxy.frontend.session.limit

session /
Type: float
haproxy.frontend.session.pct

percent /
Type: float
haproxy.frontend.session.rate

connection / second
Type: float
haproxy.frontend.session.time

millisecond /
Type: float

Metrics Conversion

Please refer to the metrics conversion document to map old metrics names to the new metric names.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.