InfluxDB is a time-series database into which you can store your HAProxy Enterprise metrics. You can then graph the data to see trends over time.
In this guide, we use Telegraf, a metrics-collections tool from InfluxData, to pull metrics from HAProxy Enterprise and push them to InfluxDB.
Installation and setup
Follow the InfluxDB Getting Started guide to install InfluxDB onto a server.
Once installed, InfluxDB hosts a UI dashboard at port 8086. Go to the InfluxDB UI at http://[INFLUXDB SERVER]:8086 and click Get Started to set up your initial user account. During setup, you will set the organization and default bucket for your data.
Go to Data > Buckets and create a new bucket named haproxy-enterprise.
Go to Data > Tokens and click Generate to create a new Read/Write token. Set the Read and Write scopes to your haproxy-enterprise bucket. Telegraf will use this token when connecting to InfluxDB.
To see an example configuraton for Telegraf, go to Data > Sources, find HAProxy in the list of Telgraf plugins, and click it.
Copy the sample configuration from the HAProxy Input Plugin page.
Follow the Introducing Telegraf guide to download and install Telegraf onto each of your HAProxy Enterprise servers. Telegraf is the service that exports metrics to InfluxDB.
Enable the Runtime API in your HAProxy Enterprise configuration to allow Telegraf to collect metrics. Configure it to listen on the UNIX socket /var/run/hapee-1.7/hapee-lb.sock:
global stats socket
/var/run/hapee-1.7/hapee-lb.sockuser hapee-lb group hapee mode 660 level admin expose-fd listeners
Add the telegraf user to the hapee group so that it has access to the Runtime API socket:
$ sudo usermod -a -G hapee telegraf
Edit the file /etc/telegraf/telegraf.conf:
[[outputs.influxdb_v2]]section and set the following fields:
urlsto the address of your InfluxDB server, which listens on port 8086
tokento the value of the Read/Write token you created in InfluxDB
organizationto the organization you set when you installed InfluxDB
[[outputs.influxdb_v2]] urls =
[http://192.168.50.26:8086]token = "IyjPRrnA5Fb4P_bHd8YBeea5K-y2DmSV_7D0wT5592YDc9v87vzQKKt-etS2YTHwbpo_gSrFQDhtBUfcDuIzXQ=="organization = "test"bucket = "haproxy-enterprise"
[[inputs.haproxy]]section. Set the
serversfield to the path of the Runtime API socket.
# Read metrics of HAProxy, via socket or HTTP stats page [[inputs.haproxy]] servers =
Restart the Telegraf and HAProxy Enterprise services:
$ sudo systemctl restart telegraf $ sudo systemctl restart hapee-1.7-lb
You can create graphs for your HAProxy Enterprise metrics in the InfluxDB UI. Go to Explore and create a new query.
For example, you could create the following query:
Set FROM to haproxy-enterprise
Set the first Filter to _measurement and select haproxy
Set the second Filter to _field and select req_rate to see the HTTP request rate
HAProxy Monitoring Template
InfluxData also provides an HAProxy monitoring template that configures a prebaked dashboard of commonly used graphs.
In the InfluxDB UI, go to Settings > Templates and enter the URL https://raw.githubusercontent.com/influxdata/community-templates/master/haproxy/haproxy.yml. Then click Install Template.
The template creates a bucket named haproxy. Generate a new Read/Write token that has access to that bucket.
Update the Telegraf configuration on your HAProxy Enterprise servers to use the new token and haproxy for the bucket value.
In the InfluxDB UI, go to Boards and click the haproxy dashboard to see the graphs.