配置数据采集socket方式和haproxy-status
# vim /etc/haproxy/haproxy.cfg
stats socket /var/lib/haproxy/admin.sock mode 600 level admin
listen stats
bind :9009
stats enable
stats uri /haproxy-status
stats realm HAProxy\ Stats\ Page
stats auth haadmin:123456
stats auth admin:123456
下载haproxy_exporter
wget https://github.com/prometheus/haproxy_exporter/releases/download/v0.13.0/haproxy_exporter-0.13.0.linux-amd64.tar.gz
tar -zxvf haproxy_exporter-0.13.0.linux-amd64.tar.gz
cp haproxy_exporter-0.13.0.linux-amd64/haproxy_exporter /usr/loucal/bin
启动haproxy_exporter
nohup haproxy_exporter --haproxy.scrape-uri=unix:/var/lib/haproxy/admin.sock &
浏览器访问9101端口看是否有数据
配置prometheus.yml
- job_name: "prometheus-haproxy-metrics"
static_configs:
- targets: ["10.211.55.20:9101"]
导入模板