在 Debian 上监控 GitLab 可以从 系统层、GitLab 服务层、应用层、以及日志/告警 四个层面来做。下面给你一套可落地的监控方案,从简单到专业都有。
GitLab 内置了 Prometheus + 自带 Exporter,这是官方推荐方式。
编辑配置文件:
sudo nano /etc/gitlab/gitlab.rb
启用监控:
prometheus_monitoring['enable'] = true
重新配置:
sudo gitlab-ctl reconfigure
访问:
http://<gitlab-ip>:9090
✅ 自带指标包括:
top / htopsudo apt install htop
htop
ps aux | grep gitlab
free -h
sudo apt install prometheus-node-exporter
启动:
sudo systemctl enable prometheus-node-exporter
sudo systemctl start prometheus-node-exporter
端口:
http://<server-ip>:9100/metrics
sudo gitlab-ctl status
sudo gitlab-rake gitlab:check
curl -s http://localhost/-/health | jq
或:
curl -I http://localhost/-/health
返回 200 OK 表示正常。
/var/log/gitlab/
常用日志:
| 日志 | 作用 |
|---|---|
gitlab-rails/production.log |
Web 请求 |
nginx/gitlab_access.log |
访问日志 |
nginx/gitlab_error.log |
错误 |
postgresql/ |
数据库 |
redis/ |
缓存 |
gitaly/ |
Git 操作 |
实时查看:
sudo tail -f /var/log/gitlab/gitlab-rails/production.log
GitLab → Prometheus → Grafana
官方 Dashboard:
可监控:
#!/bin/bash
if ! curl -s http://localhost/-/health | grep -q "ok"; then
echo "GitLab is down" | mail -s "GitLab Alert" admin@example.com
fi
| 指标 | 警戒值 |
|---|---|
| CPU | > 80% |
| 内存 | > 85% |
| 磁盘 | > 80% |
| 并发连接 | > 500 |
| 500 错误 | > 1% |
| Sidekiq 队列 | 持续增长 |
✅ 中小团队
gitlab-ctl statushtop/var/log/gitlab✅ 生产环境
你可以告诉我:
我可以直接给你: