ubuntu14.04 grafana暂时haproxy配置

一,拉取docker镜像

docker pull prom/haproxy-exporter

二、添加prometheus配置,sudo vim /etc/prometheus/prometheus.yml,注意:instance命令要host:port,为了兼容grafana的dashboards

 # haproxy
  - job_name: 'haproxy'
    static_configs:
      - targets: ['172.17.0.1:9101']
        labels:
          instance: haproxy:9101

三、配置haproxy服务

listen stats
    bind 0.0.0.0:1080
    mode http
    option  httplog
    log     global
    stats enable
    stats refresh 30s
    stats uri /admin?stats
    stats realm Private lands
    stats auth user:pass
    stats hide-version
    stats admin if TRUE

四、docker启动haproxy镜像

docker run -d \
  -p 9101:9101 \
  --restart=always \
  prom/haproxy-exporter \
  --haproxy.scrape-uri="http://user:[email protected]/haproxy?stats;csv"

五,在grafana下载haproxy的dashboards

wget https://grafana.com/api/dashboards/2428/revisions/6/download -O haproxy_rev6.json

六、导入haproxy_rev6.json文件

ubuntu14.04 grafana暂时haproxy配置

七、grafana展示效果

ubuntu14.04 grafana暂时haproxy配置

八、参考