prometheus通过haproxy_exporter监控haproxy

722人浏览 / 0人评论

一、部署haproxy_exporter (部署安装比较简单,不做细说)

二、启动haproxy_exporter

[root@ haproxy_exporter]# cat start.sh 
#!/bin/bash

nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9020 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9022 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/stats\;csv --web.listen-address=:9024 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9026 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9032 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9034 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/haproxyadmin?stats\;csv --web.listen-address=:9028 &
nohup ./haproxy_exporter --haproxy.scrape-uri=http://admin:密码@ip:端口/stats\;csv --web.listen-address=:9030 &

 查看端口

 

三、使用consul注册

1、编写json文件

[root@ops-consul-32-34 haproxy-exporter]# cat 192.168.36.16.json 
{
  "ID": "ops-software-haproxy-ip",
  "Name": "ops-haproxy",
  "Tags": [
    "ops-haproxy"
  ],
  "Address": "haproxy_exporter_ip",
  "Port": 端口,
  "Meta": {
    "type": "host",
    "team": "ops",
    "ip": "haproxyIP"
  },
  "EnableTagOverride": false,
  "Check": {
    "HTTP": "http://haproxy_exporter_ip:端口/metrics",
    "Interval": "10s"
  },
  "Weights": {
    "Passing": 10,
    "Warning": 1
  }
}

2、进行注册

 [root@ haproxy-exporter]# cat create.sh 
#!/bin/bash
host=$1

curl -X PUT  http://consulIP:8500/v1/agent/service/register -d @${host}
curl -X PUT  http://consulIP:8500/v1/agent/service/register -d @${host}
curl -X PUT  http://consulIP:8500/v1/agent/service/register -d @${host}

全部评论