A lightweight Prometheus exporter that collects and exposes GitLab CI/CD pipeline metrics for specific projects and groups. This allows you to monitor the health, duration, and success rates of pipelines in GitLab using Prometheus and Grafana.
- Collects the total number of pipelines per status (success, failed, running, etc.)
- Exposes the latest pipeline duration (in seconds)
- Provides a probe success metric to track scraping health
- Supports GitLab group/project query parameters for flexible scraping
- Simple and minimal — ideal for per-project monitoring setups
docker run -p 9115:9115 ghcr.io/aleksanderwww/prometheus-gitlabci-exporter:0.1.0alternatively, with another port
docker run -p 8000:8000 ghcr.io/aleksanderwww/prometheus-gitlabci-exporter:0.1.0 --web.port=:8000wget https://github.com/AleksanderWWW/prometheus-gitlabci-exporter/releases/download/0.1.0/prometheus_gitlabci_exporter-0.1.0.tar.gz
tar -xzf prometheus_gitlabci_exporter-0.1.0.tar.gz
chmod +x prometheus_gitlabci_exporter
./prometheus_gitlabci_exportergit clone https://github.com/AleksanderWWW/prometheus-gitlabci-exporter.git
cd prometheus-gitlabci-exportergo build -o prometheus_gitlabci_exporterYou can provide your GitLab API token either via flag or environment variable.
export GITLAB_API_TOKEN="glpat-yourtoken"
./prometheus_gitlabci_exporteror
./prometheus_gitlabci_exporter --api.token="glpat-yourtoken"| Flag | Description | Default |
|---|---|---|
--api.token |
GitLab API token used to authenticate requests | (required) |
--web.port |
Address and port to listen on | :9115 |
./gitlabci-exporter \
--api.token="glpat-yourtoken" \
--web.port=":9115"The exporter exposes a /probe HTTP endpoint which Prometheus can scrape dynamically.
curl "http://localhost:9115/probe?group=my-group&project=my-project"# HELP gitlab_pipeline_total Total number of pipelines for the target project.
# TYPE gitlab_pipeline_total counter
gitlab_pipeline_total{group="my-group",project="my-project",status="success"} 12
gitlab_pipeline_total{group="my-group",project="my-project",status="failed"} 3
...
# HELP gitlab_pipeline_last_duration_seconds Duration of the latest pipeline in seconds.
# TYPE gitlab_pipeline_last_duration_seconds gauge
gitlab_pipeline_last_duration_seconds 154.23
# HELP gitlab_probe_success Whether the probe was successful (1 - success, 0 - failure).
# TYPE gitlab_probe_success gauge
gitlab_probe_success 1
+-------------------+ +-------------------+
| Prometheus Server | <------> | Exporter (/probe) |
+-------------------+ +-------------------+
|
v
GitLab API (Client)
The exporter:
- Accepts HTTP requests from Prometheus with
groupandprojectquery parameters. - Queries the GitLab API to list pipelines and get the latest one’s duration.
- Exposes aggregated metrics over
/probe.
Add this job to your prometheus.yml:
scrape_configs:
- job_name: 'gitlabci_exporter'
metrics_path: /probe
static_configs:
- targets:
- 'localhost:9115'
params:
group: ['my-group']
project: ['my-project']| Metric | Type | Description |
|---|---|---|
gitlab_pipeline_total |
Counter | Number of pipelines by status |
gitlab_pipeline_last_duration_seconds |
Gauge | Duration of the latest pipeline |
gitlab_probe_success |
Gauge | Indicates if the exporter successfully queried GitLab |
gitlab_host |
Gauge | Host name of the GitLab instance |
exporter_probe_duration_seconds |
Gauge | Duration of the probe in seconds |
| Variable | Description |
|---|---|
GITLAB_API_TOKEN |
GitLab API token (used if --api.token flag not provided) |
MIT License © 2025 AleksanderWWW