Using Prometheus to Monitor GitLab Runner and GitLab CI Pipelines
This guide explains how to enable Prometheus metrics on GitLab Runner, configure the runner’s HTTP endpoint, collect the metrics with Prometheus, and visualize both runner and CI pipeline data in Grafana using ready‑made dashboards.
GitLab Runner exposes Prometheus metrics via an embedded HTTP server at the /metrics endpoint. By enabling this endpoint—either by setting listen_address in config.toml or by adding the --listen-address flag when starting the runner—you can let Prometheus scrape runner‑specific metrics such as job counts, Go runtime statistics, and general system metrics.
Example config.toml configuration:
listen_address = "[::]:9252"
concurrent = 10
check_interval = 30
log_level = "info"After restarting the runner, verify the listening port with:
bash-5.0$ netstat -anlpt | grep 9252When port 9252 is LISTEN, the metrics endpoint is reachable. Retrieve a sample of the metrics with:
curl 127.0.0.1:9252/metricsNext, add a job to the Prometheus configuration to scrape the runner metrics:
- job_name: 'gitlab-runner'
metrics_path: '/metrics'
scheme: http
bearer_token: bearer_token
static_configs:
- targets: ['192.168.1.200:30092']Visit http://192.168.1.200:30003/new/targets to confirm the target is up, then import a Grafana dashboard (e.g., dashboard 9631 ) to visualize the runner metrics.
1.2 Configuring GitLab CI Pipeline Monitoring
To obtain a unified view of CI/CD pipeline status across projects, deploy the gitlab-ci-pipelines-exporter . Clone the exporter repository, edit values.yaml to set the GitLab URL and token, and install the Helm chart:
git clone https://github.com/mvisonneau/gitlab-ci-pipelines-exporter.git
vim chart/values.yaml
# edit the gitlab section with URL and token
helm install gitlabci-pipeline-exporter --namespace gitlab-runner ./chartExtend the Prometheus configuration with a new job for the exporter:
- job_name: 'gitlab-runner-ci-pipeline'
metrics_path: '/metrics'
scheme: http
bearer_token: bearer_token
static_configs:
- targets: ['10.1.234.132:80']Finally, import a Grafana dashboard for CI pipeline metrics (e.g., dashboard 10620 ) to display pipeline health alongside runner statistics.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.