在 Linux 上监控 GitLab,通常从 系统资源、GitLab 服务状态、应用性能、日志、告警 几个层面来做。下面给你一套从基础到进阶的完整方案,适合生产环境。
top
htop
free -h
df -h
iostat -x 1
htop:进程 & CPUiotop:磁盘 IOnetstat / ss:端口 & 连接vmstat:系统整体负载✅ 重点指标
/var/opt/gitlab)GitLab 自带服务管理命令:
gitlab-ctl status
查看单个组件:
gitlab-ctl status nginx
gitlab-ctl status sidekiq
gitlab-ctl status puma
✅ 常见关键服务:
puma(Web)sidekiq(后台任务)postgresqlredisnginxgitalyGitLab 自带 Prometheus,无需额外安装。
gitlab-ctl status prometheus
访问:
http://gitlab_ip:9090
GitLab 企业版(EE)自带 Grafana
社区版(CE)可手动对接 Prometheus
路径:
Admin → Monitoring → Metrics
✅ 推荐监控面板:
/var/log/gitlab/
关键日志:
gitlab-rails/production.log
sidekiq.log
nginx/gitlab_access.log
nginx/gitlab_error.log
postgresql/postgresql.log
redis/redis.log
gitaly/current
tail -f /var/log/gitlab/gitlab-rails/production.log
✅ 关注:
curl http://gitlab.local/-/health
返回:
GitLab OK
详细状态:
curl http://gitlab.local/-/readiness
curl http://gitlab.local/-/liveness
✅ 可用于:
GitLab 集成 Alertmanager:
gitlab-ctl status alertmanager
默认告警规则:
✅ 可接入:
架构:
GitLab → Prometheus → Grafana
✅ 适合:
GitLab exporter 自动暴露:
http://gitlab_ip:9100/metrics
Zabbix 监控项:
| 指标 | 说明 |
|---|---|
| 并发请求数 | Puma |
| Sidekiq 队列长度 | 后台任务 |
| DB 连接数 | PostgreSQL |
| Redis 命中率 | 缓存 |
| Gitaly 延迟 | Git 操作 |
| 磁盘 IO | 仓库增长 |
✅ 中小型
gitlab-ctl status✅ 生产环境
| 问题 | 监控点 |
|---|---|
| 502 | nginx / puma |
| 慢 | DB / Gitaly |
| 卡顿 | Sidekiq |
| 磁盘满 | repo 增长 |
| 内存爆 | sidekiq + puma |
如果你愿意,我可以帮你:
你现在用的是 GitLab CE 还是 EE?单机还是高可用?