在 CentOS 上运行的 GitLab 监控通常分为 系统级监控、GitLab 自身状态监控、日志监控、以及外部监控系统接入(Prometheus / Grafana / Zabbix 等)。下面按实用层次详细说明。
GitLab 默认集成 Prometheus(尤其 Omnibus 安装方式)。
查看是否启用:
grep -R prometheus /etc/gitlab/gitlab.rb
启用 Prometheus:
gitlab_rails['monitoring_whitelist'] = ['127.0.0.1']
prometheus['enable'] = true
prometheus_monitoring['enable'] = true
重新配置:
gitlab-ctl reconfigure
访问:
http://<gitlab_ip>:9090
查看指标:
process_resident_memory_bytes
gitlab_workhorse_requests_total
✅ 优点:
gitlab-ctl status
查看单个服务:
gitlab-ctl status nginx
gitlab-ctl status redis
gitlab-ctl status postgresql
curl http://localhost/-/health
或:
curl http://localhost/-/readiness
curl http://localhost/-/liveness
返回值:
200 ✅ 正常500/503 ❌ 异常top
htop
free -h
df -h
| 组件 | 说明 |
|---|---|
| Sidekiq | 后台任务,CPU 高 |
| PostgreSQL | 内存消耗大 |
| Gitaly | Git 仓库访问 |
| Redis | 缓存 |
查看进程:
ps aux | grep gitlab
/var/log/gitlab/
关键日志:
| 日志 | 作用 |
|---|---|
| gitlab-rails/production.log | 主应用 |
| sidekiq/current | 后台任务 |
| nginx/gitlab_access.log | 访问 |
| postgresql/postgresql.log | 数据库 |
| gitaly/current | Git 操作 |
实时查看:
tail -f /var/log/gitlab/gitlab-rails/production.log
GitLab → Prometheus → Grafana
http://localhost:9090GitLab 官方 Grafana Dashboard:
https://grafana.com/grafana/dashboards/11264
包含:
| 监控项 | 方法 |
|---|---|
| GitLab 服务状态 | gitlab-ctl status |
| HTTP 可用性 | curl -s -o /dev/null -w "%{http_code}" |
| 磁盘 | Zabbix Agent |
| 内存 | Zabbix Agent |
| PostgreSQL 连接数 | SQL 查询 |
✅ 必看指标
✅ 告警阈值建议
| 场景 | 方案 |
|---|---|
| 小型团队 | GitLab 自带 Prometheus |
| 企业级 | Prometheus + Grafana |
| 传统运维 | Zabbix |
| DevOps | GitLab + Prometheus + Alertmanager |
如果你愿意,我可以:
直接告诉我你的 GitLab 安装方式(Omnibus / Docker / 源码)即可。