Debian 上 Jenkins 性能监控实操指南
一 监控分层与总体架构
二 快速落地步骤 Prometheus Grafana
scrape_configs:
- job_name: 'jenkins'
metrics_path: '/prometheus/'
scheme: http
bearer_token: <your_jenkins_token>
static_configs:
- targets: ['jenkins_server_ip:8080']
三 系统层与 JVM 层监控
sar -u -r -x 1 60),配合 iostat -x 1 定位磁盘瓶颈;用 iftop/nethogs 观察网络与进程流量异常;top/htop 快速排查高占用进程。sudo systemctl status jenkinstop/htop、iostat -x 1、iftop/nethogsdu -sh $JENKINS_HOME,定期清理旧构建与归档工件,防止 磁盘耗尽 导致实例不稳定。四 告警与 SLA 实践
groups:
- name: jenkins.rules
rules:
- alert: JenkinsQueueTooLong
expr: jenkins_queue_size > 20
for: 5m
labels:
severity: warning
annotations:
summary: "Jenkins 构建队列积压过高"
description: "当前队列长度 {{ $value }} 超过阈值 20,持续 5 分钟。"
- alert: JenkinsNodeOffline
expr: jenkins_node_status{status="offline"} > 0
for: 2m
labels:
severity: critical
annotations:
summary: "Jenkins 节点离线"
description: "有 {{ $value }} 个节点处于离线状态。"
五 常见问题与优化建议