使用jenkins exporter 监控jenkins 构建任务

jenkins 提供了rest api,我们可以基于rest api 暴露prometheus metrics,社区已经有了好多
开源的实现了,使用起来也比较方便,以下集成几个进行简单的测试

环境准备

  • docker-compose 文件
 
version: "3"
services: 
    jenkins: 
      image: jenkins/jenkins:lts-slim
      ports:
      - "8080:8080"
    jenkins-exporter2:
      image: tboerger/jenkins-exporter
      command: -jenkins.address=http://jenkins:8080 -jenkins.password=dalong -jenkins.username=admin
      ports:
      - "9103:9103"
    jenkins-exporter3:
      image: tolleiv/jenkins_exporter
      command: -j=http://jenkins:8080 --password=dalong --user=admin
      ports:
      - "9119:9118"
    jenkins-exporter:
      image: dalongrong/jenkins_exporter
      env_file:
      - .env
      ports:
      - "9118:9118"
    grafana:
      image: grafana/grafana    
      ports:
      - "3000:3000"
    prometheus:
      image: prom/prometheus
      volumes:
      - "./prometheus.yml:/etc/prometheus/prometheus.yml"
      ports:
      - "9090:9090"  
  • promethesu 配置
scrape_configs:
  - job_name: jenkins
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets: ['jenkins-exporter:9118']
  - job_name: jenkins2
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets: ['jenkins-exporter2:9103']
  - job_name: jenkins3
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets: ['jenkins-exporter3:9118']
  • 简单说明
    包含了三个exporter tboerger/jenkins-exporter ,tolleiv/jenkins_exporter,akawork/Jenkins-exporter
    使用方法很简单,同时也集成了一个基于docker 的jenkins,方便测试

启动&&测试

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

 

 

  • jenkins 任务

 

 

 

说明

以上是一个简单的集成三个exporter 进行测试,还是很方便的,可以快速的查看任务的构建的状态

参考资料

https://github.com/akawork/Jenkins-exporter.git
https://github.com/akawork/Jenkins-exporter
https://github.com/rongfengliang/jenkins-exporter-prometheus

posted on   荣锋亮  阅读(2640)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2018-08-31 openresty 使用cuid 类库生成短链接id
2018-08-31 比jsonpath 更方便的json 数据查询JMESPath 使用
2018-08-31 streamsets 集成 rabbitmq 以及benthos stream 处理框架
2014-08-31 asp.net MVC 使用wifidog 协议实现wifi认证

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示