在 Debian 上运行的 GitLab(通常是 Omnibus 包安装)可以从 系统层、GitLab 自身、应用层、以及外部监控 几个维度来做监控。下面给你一套实用方案。
GitLab Omnibus 默认集成了 Prometheus + Grafana。
启用(通常默认已启用):
sudo gitlab-ctl reconfigure
配置文件 /etc/gitlab/gitlab.rb:
prometheus['enable'] = true
grafana['enable'] = true
访问:
http://<gitlab-ip>:9090http://<gitlab-ip>:3000常用监控项:
gitlab_workhorse_requestsrails_requestspostgres_stat_databaseredis_upunicorn_active_connections# 基本健康
sudo gitlab-rake gitlab:check
# 服务状态
sudo gitlab-ctl status
Web 健康检查:
https://gitlab.example.com/-/health
top / htop
df -h
free -m
journalctl -u gitlab-runsvdir
sudo apt install prometheus-node-exporter
Prometheus 采集:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
GitLab 包含以下核心组件,都需要关注:
| 组件 | 监控方式 |
|---|---|
| Nginx | nginx_status |
| Puma / Unicorn | Prometheus |
| Sidekiq | Prometheus |
| PostgreSQL | postgres_exporter |
| Redis | redis_exporter |
| Gitaly | Prometheus |
查看组件状态:
sudo gitlab-ctl status
/var/log/gitlab/
重点日志:
gitlab-rails/production.logsidekiq/currentnginx/gitlab_error.loggitaly/currentsudo gitlab-ctl tail
sudo gitlab-ctl tail sidekiq
示例告警:
https://gitlab.example.com/-/healthsudo gitlab-rake gitlab:backup:create
监控:
✅ GitLab + Prometheus + Grafana + node_exporter + Alertmanager
如果你愿意,我可以:
你现在是 自建 GitLab 还是 GitLab CE/EE?规模多大?