Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active May 21, 2021 22:22
Show Gist options
  • Save haproxytechblog/afff5e45d4ede85e9825690278e29d01 to your computer and use it in GitHub Desktop.
Save haproxytechblog/afff5e45d4ede85e9825690278e29d01 to your computer and use it in GitHub Desktop.
Visualize HAProxy Metrics with InfluxDB
global
stats socket /run/haproxy/api.sock mode 660 level admin
$ sudo mkdir /run/haproxy
$ export INFLUXDB_TOKEN="<Insert InfluxDB token here>"
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.
## urls exp: http://127.0.0.1:9999
urls = ["http://127.0.0.1:8086"]
## Token for authentication.
# token = "$INFLUX_TOKEN" # Uncomment to use environment variable
token = "Your InfluxDB token" # Plain text token
## Organization is the name of the organization you wish to write to; must exist.
organization = "haproxy"
## Destination bucket to write into.
bucket = "haproxy"
[[inputs.haproxy]]
servers = ["socket:/run/haproxy/api.sock"]
$ sudo systemctl stop telegraf
$ telegraf --config /etc/telegraf/telegraf.conf
2021-04-23T00:01:17Z I! Starting Telegraf 1.18.1
2021-04-23T00:01:17Z I! Loaded inputs: haproxy
2021-04-23T00:01:17Z I! Loaded aggregators:
2021-04-23T00:01:17Z I! Loaded processors:
2021-04-23T00:01:17Z I! Loaded outputs: influxdb_v2
2021-04-23T00:01:17Z I! Tags enabled: host=spion
2021-04-23T00:01:17Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"my-haproxy", Flush Interval:10s
$ sudo systemctl start telegraf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment