使用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']
- 简单说明
包含了三个exportertboerger/jenkins-exporter
,tolleiv/jenkins_exporter
,akawork/Jenkins-exporter
使用方法很简单,同时也集成了一个基于docker 的jenkins,方便测试
启动&&测试
- 启动
docker-compose up -d
- 效果
- jenkins 任务
- grafana 配置
导入github 项目的json 文件https://github.com/rongfengliang/jenkins-exporter-prometheus/blob/master/jenkins-exporter_rev1.json
效果
说明
以上是一个简单的集成三个exporter 进行测试,还是很方便的,可以快速的查看任务的构建的状态
参考资料
https://github.com/akawork/Jenkins-exporter.git
https://github.com/akawork/Jenkins-exporter
https://github.com/rongfengliang/jenkins-exporter-prometheus
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.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认证