haproxy prometheus 的监控metrics 使用的是exporter ,因为haproxy 对于状态统计报告处理的
比较好,我们可以了stats 同时支持一个csv的api 接口,所以exporter也是基于这个搞的开发,同时
里面对于不同版本的haproxy 做了适配

环境准备

  • docker-compose 文件
 
version: "3"
services:
  haproxy:
    image: haproxy:1.7
    ports:
    - "5000:5000"
    - "10080:10080"
    volumes:
    - "./conf/haproxy:/usr/local/etc/haproxy:ro"
  exporter:
    image: quay.io/prometheus/haproxy-exporter:v0.9.0
    command: --haproxy.scrape-uri="http://admin:password@haproxy:10080/haproxy?stats;csv"
    ports:
    - "9101:9101"
  g:
    image: grafana/grafana
    ports:
    - "3000:3000"
  p:
    image: prom/prometheus
    volumes:
    - "./conf/prometheus.yml:/etc/prometheus/prometheus.yml"
    ports:
    - "9090:9090"
 
 
  • haproxy 配置文件
    conf/haproxy/haproxy.cfg 很简单就是配置了stats 同时配置了一个简单的jenkins 的proxy+ lb
 
global
    log 127.0.0.1 local2
    maxconn 4000
    # turn on stats unix socket
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode http
    log global
    option httplog
    option dontlognull
    option http-server-close
    option forwardfor except 127.0.0.0/8
    option redispatch
    retries 3
    timeout http-request 10s
    timeout queue 1m
    timeout connect 10s
    timeout client 1m
    timeout server 1m
    timeout http-keep-alive 10s
    timeout check 10s
    maxconn 3000
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
    bind 0.0.0.0:5000
    default_backend app
backend app
    balance roundrobin
    server app1 10.15.0.80:80 check
    server app2 10.15.0.80:8080 check
    server app3 127.0.0.1:5003 check
    server app4 127.0.0.1:5004 check
listen stats
        bind 0.0.0.0:10080
        mode http
        log global
        maxconn 10
        clitimeout 100s
        srvtimeout 100s
        contimeout 100s
        timeout queue 100s
        stats enable
        stats hide-version
        stats refresh 30s
        stats show-node
        stats auth admin:password
        stats uri /haproxy?stats
 
 
  • exporter 配置
    主要是启动的时候指定haproxy server 的地址,因为使用了basic auth, exporter 比较方便支持basic auth 格式的url
 
  command: --haproxy.scrape-uri="http://admin:password@haproxy:10080/haproxy?stats;csv"
 
  • prometheus 配置
    实际上就是通过静态配置添加experter 地址 ./conf/prometheus.yml
 
scrape_configs:
  - job_name: haproxy
    metrics_path: /metrics
    static_configs:
      - targets: ['exporter:9101']
 
 

运行&&效果

  • 启动
docker-compose up -d
 
  • 访问效果




说明

docker-compose文件同时集成了grafana,可以方便的进行UI的可视化展示

参考资料

https://github.com/rongfengliang/haproxy_promethues-docker-compose
https://github.com/prometheus/haproxy_exporter
https://hub.docker.com/_/haproxy

haproxy prometheus 监控docker-compose 运行试用的更多相关文章

  1. Prometheus监控Docker Swarm集群(一)

    Prometheus监控Docker Swarm集群(一) cAdvisor简介 为了解决容器的监控问题,Google开发了一款容器监控工具cAdvisor(Container Advisor),它为 ...

  2. Prometheus 监控Docker服务器及Granfanna可视化

    Prometheus 监控Docker服务器及Granfanna可视化 cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息. 使用Prometheus监控c ...

  3. Grafana连接Prometheus监控Docker平台

    Grafana是一款开源的分析平台. Grafana allows you to query, visualize, alert on and understand your metrics no m ...

  4. dotnet跨平台 - 使用Nginx+Docker Compose运行.NETCore项目

    参考文档: https://docs.docker.com/install/linux/docker-ce/centos/ http://www.dockerinfo.net/document htt ...

  5. Prometheus入门到放弃(4)之cadvisor监控docker容器

    Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行. 1.下载镜像 [root@prometheus-server ...

  6. .NET遇上Docker - 使用Docker Compose组织Ngnix和.NETCore运行

    本文工具准备: Docker for Windows Visual Studio 2015 与 Visual Studio Tools for Docker 或 Visual Studio 2017 ...

  7. prometheus监控(小试牛刀)

    prometheus监控(小试牛刀) 环境:全部服务都是基于docker运行 本文略微草率,好文章在这里,特别好如下: https://www.cnblogs.com/tchua/p/11120228 ...

  8. 6. 使用cadvisor监控docker容器

    Prometheus监控docker容器运行状态,我们用到cadvisor服务,cadvisor我们这里也采用docker方式直接运行.这里我们可以服务端和客户端都使用cadvisor 客户端 1.下 ...

  9. Docker:Docker Compose 详解

    Docker Compose 概述与安装? 前面我们使用 Docker 的时候,定义 Dockerfile 文件,然后使用 docker build.docker run 等命令操作容器.然而微服务架 ...

随机推荐

  1. Integer与int的区别(转)

    如果面试官问Integer与int的区别:估计大多数人只会说道两点,Ingeter是int的包装类,int的初值为0,Ingeter的初值为null.但是如果面试官再问一下Integer i = 1; ...

  2. python中处理.db文件借助navicat

    navicat premium 12  中可以点击“连接” --sqllite 然后选择.db等文件导入 即可再导成..csv等格式.

  3. [SCOI2005]栅栏

    这个题...只能说比较水... 排序后,算一个前缀和,二分dfs查找答案...加上两个剪枝就过了...QVQ 我只能刷这种水题...我太菜了...QVQ #include<iostream> ...

  4. POJ - 1850 B - Code

    Transmitting and memorizing information is a task that requires different coding systems for the bes ...

  5. pytest的执行规则和顺序

    用例运行级别 模块级(setup_module/teardown_module)开始于模块始末,全局的 函数级(setup_function/teardown_function)只对函数用例生效(不在 ...

  6. python文件和文件流操作

    f = open(r'C:\Users\wangxue2\Desktop\somefile.txt', 'w') #r'C:\Users\wangxue2\Desktop\somefile.txt'中 ...

  7. Beta阶段冲刺---Day5

    一.Daily Scrum Meeting照片 二.今天冲刺情况反馈 昨天已完成的工作: (1)闯关模式界面设计: (2)主界面做了相应修改: (3)RankActivity修改. (4)RANKli ...

  8. Maven Speed Up

    收录架构 proxy代理仓库 不支持仓库搜索功能 收录版本 所有版本 更新时间 每24小时更新一次 使用说明 一.在maven软件中使用 以Maven 3.5.2为例: 打开maven配置文件 ./a ...

  9. CountDownLatch & CyclicBarrier

    CountDownLatch 在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待.用给它的代数初始化CountDownLatch,且计数器无法被重置.当前计数到达0之前,await方 ...

  10. 全卷积神经网络FCN

    卷积神经网络CNN(YannLecun,1998年)通过构建多层的卷积层自动提取图像上的特征,一般来说,排在前边较浅的卷积层采用较小的感知域,可以学习到图像的一些局部的特征(如纹理特征),排在后边较深 ...