/GitLab-Activity-Exporter

🔍 Prometheus exporter for GitLab metrics, providing deep insights into project statistics, contributor activities, and repository analytics

Primary LanguageGoMIT LicenseMIT

GitLab Activity Exporter

Prometheus exporter for GitLab metrics providing deep Activity into project statistics, contributor activities, and repository analytics.

Features

  • Project statistics collection (commits, storage, artifacts)
  • Contributor activity tracking
  • Multi-group support
  • Rate-limited API requests
  • Pattern-based filtering
  • Prometheus metrics endpoint
  • Multi-platform support

Metrics Reference

Project Metrics

Metric Name Type Description Labels Unit
gitlab_project_commits_total Gauge Total number of commits project Count
gitlab_project_storage_bytes Gauge Total storage size project Bytes
gitlab_project_repository_bytes Gauge Repository size project Bytes
gitlab_project_artifacts_bytes Gauge CI/CD artifacts size project Bytes
gitlab_project_packages_bytes Gauge Package registry size project Bytes

Contributor Metrics

Metric Name Type Description Labels Unit
gitlab_contributor_commits_total Gauge Number of commits by contributor project, email Count

Configuration

Configuration file format:

gitlab:
  api_url: "https://gitlab.company.com/api/v4"
  token: "glpat-xxxxxxxxxxxxxxxxxxxx"
  max_concurrent_requests: 20
  timeout: 45s

projects:
  groups:
    - path: "production"
      recursive: true
    - path: "development"
      recursive: false
  refresh_interval: 30m

filters:
  projects:
    include_patterns:
      - "^production/.+"
    exclude_patterns:
      - ".+[-_]archive$"
  contributors_email:
    include_patterns:
      - "@company\\.com$"
    exclude_patterns:
      - "bot@.+"

exporter:
  host: "0.0.0.0"
  port: 9199
  metrics_path: "/metrics"
  collection_interval: 1m
  log_level: "info"

Installation

Pre-built Binaries

Download from releases page:

wget https://github.com/your-repo/gitlab-аctivity-exporter/releases/latest/download/gitlab-аctivity-exporter-linux-amd64
chmod +x gitlab-аctivity-exporter-linux-amd64

Build from Source

Requirements:

  • Go 1.21+
  • Docker (for multi-platform builds)
git clone https://github.com/your-repo/gitlab-аctivity-exporter.git
cd gitlab-аctivity-exporter
./build.sh

Usage

  1. Create configuration file
  2. Execute:
./gitlab-аctivity-exporter -c config.yml

Metrics endpoint: http://localhost:9199/metrics

Command Line Options

  • -c, --config: Configuration file path (default: "config.yml")
  • -v, --version: Version information
  • -h, --help: Help message

Prometheus Integration

scrape_configs:
  - job_name: 'gitlab_аctivity'
    static_configs:
      - targets: ['localhost:9199']

Development

Project Structure

/
├── cmd/            # Application entry
├── internal/
│   ├── collector/  # Metric collectors
│   ├── config/     # Configuration
│   ├── gitlab/     # GitLab client
│   ├── metrics/    # Prometheus metrics
│   ├── project/    # Project management
│   └── filter/     # Pattern matching

Grafana Dashboard

dashboard template GitLab Activity Dashboard