Prometheus监控Haproxy

这里只是对prometheus监控haproxy的配置过程做个记录,方便以后查阅。

1.下载haproxy_exporter

1
https://github.com/prometheus/haproxy_exporter

2.配置haproxy_exporter

1
2
tar xf downloads/haproxy_exporter-0.10.0.linux-amd64.tar.gz
mv -f haproxy_exporter-0.10.0.linux-amd64/ haproxy_exporter

3.启动haproxy_exporter

1
/work/admin/haproxy_exporter/haproxy_exporter --haproxy.scrape-uri="http://192.168.6.214:8888/status?stats;csv" --web.listen-address=":9101"

4.prometheus配置

1
2
3
4
5
6
7
8
9
10
- job_name: 'lan'
static_configs:
- targets: ['192.168.6.212:9100']
labels: {cluster: 'product',type: 'basic',env: 'lan',job: 'lan1',export: 'lan1'}
- targets: ['192.168.6.212:9101']
labels: {cluster: 'product',type: 'middle',env: 'lan',job: 'lan1',export: 'haproxy_exporter'}
- targets: ['192.168.3.93:9100']
labels: {cluster: 'product',type: 'basic',env: 'lan',job: 'lan2',export: 'lan2'}
- targets: ['192.168.3.93:9101']
labels: {cluster: 'product',type: 'middle',env: 'lan',job: 'lan2',export: 'haproxy_exporter'}

重启prometheus

如果开启了api管理功能,可以如下方式热加载配置

1
curl -X POST http://127.0.0.1:9090/-/reload

5.grafana出图

推荐使用6551

效果如下

-------------本文结束感谢您的阅读-------------