Table of Contents

Update Date: July 30, 2025

Overview

GitLab Usage Analysis System is a professional GitLab data analysis tool that can collect, analyze and visualize your GitLab project data. Through Elasticsearch storage combined with Grafana dashboards, it provides comprehensive project usage insights.

Analysis Results Showcase

Commits Analysis

Supports multiple filtering conditions, can view from multiple dimensions such as project, committer, lines changed.

Commits Analysis Interface

Projects Statistics

Projects Statistics Interface

Users Activity

Users Activity Interface

Merge Requests Analysis

Merge Requests Analysis Interface

System Requirements

Minimum Configuration Requirements

  • Operating System: Docker-supported OS (Windows 10+, macOS 10.14+, Ubuntu 18.04+ or other Linux distributions)
  • Memory: 4GB RAM (8GB or more recommended)
  • Disk Space: At least 10GB available space
  • Network: Need access to GitLab and Elasticsearch cluster and Grafana instance

Dependencies

Deployment and Configuration

1Prepare Configuration File

  1. 创建 config.yaml 配置文件
  2. 编辑配置文件,设置以下关键参数:
# Login user configuration (required)
AUTH_USERNAME: admin
AUTH_PASSWORD: admin
AUTH_COOKIE_DURATION: 1000000

# GitLab configuration (can be configured later via UI)
GITLAB_URL: https://your-gitlab-instance.com
GITLAB_PAT: your-gitlab-access-token

# Elasticsearch configuration (can be configured later via UI)
ELASTICSEARCH_URL: http://your-elasticsearch:9200
ELASTICSEARCH_USER: es-username # if authentication required
ELASTICSEARCH_PASSWORD: es-password # if authentication required

# Grafana configuration (can be configured later via UI)
GRAFANA_URL: http://your-grafana:3000
GRAFANA_USERNAME: gf-username
GRAFANA_PASSWORD: gf-password

创建 config.yaml 完成后,为确保容器内用户可以操作文件,可以对其设置为任何用户可读写:

chmod 666 config.yaml

2Deploy with Docker

使用以下命令启动系统:

# Start new container
docker run -itd --name gua \
  -p 8081:8081 \
  -v /path/to/your/config.yaml:/srv/config.yaml \
  rourin/gitlab-usage-analysis:1.0.0

# View logs
docker logs -f gua

注意事项

  • /path/to/your/config.yaml 替换为您实际的配置文件路径
  • 系统将在端口 8081 上运行,可以自行修改映射其他主机端口

3First Access

  1. 启动后,在浏览器中访问 http://localhost:8081
  2. 系统将引导您完成初始化设置
初始化设置界面

初始化密码完成后可以登录进入首页:

系统首页

System Interface Description

1. Homepage

Homepage displays system basic status and overview information, such as current GitLab/Elasticsearch/Grafana configuration.

系统首页界面

功能说明:

  1. 初始化索引为 Elasticsearch 初始化必要的索引,仅在第一次运行统计前操作
  2. 配置跳转到配置页
  3. 检查项目跳转到检查项目页,用于对群组或者项目的大提交数目分析
  4. 运行统计运行核心分析程序
  5. 启用定时任务周期性更新使用数据

2. Project Check

Project check page is used to analyze GitLab projects before running statistics.

项目检查界面

分析完成后的典型样例为:

项目检查结果

3. Configuration

Configuration page is used to manage various system settings.

配置界面1 配置界面2

主要功能:

4. Authentication Configuration

Authentication configuration page manages system access permissions and licenses.

认证配置界面

主要功能:

5. Logs

Logs page displays system operation logs and status information.

日志界面

主要功能:

6. Dashboard

Dashboard page provides data analysis and visualization functions.

仪表板界面

主要功能:

统计信息:

Usage Limitations

No License Mode

Without a valid license, the system will run in trial mode with the following limitations:

  • Maximum 5 projects analysis
  • Maximum 100 commit records per project
  • Maximum 10 merge requests per project
  • Maximum 10 user accounts

License Mode

After importing a valid license, all usage restrictions will be lifted, you can:

  • Analyze unlimited number of projects
  • Collect complete commit history
  • Analyze all merge request data
  • Support unlimited number of users

Appendix

Grafana Deployment

  1. 创建数据路径,并授予所有用户读写权限:
    mkdir -p /srv/grafana/data
    chmod -R a+rw /srv/grafana/data
  2. 启动 Grafana:
    docker run -itd --restart always --name=grafana \
      --net=host \
      -p 3000:3000 \
      -v /srv/grafana/data:/var/lib/grafana \
      -e "GF_LOG_LEVEL=debug" \
      grafana/grafana:11.4.0
  3. 访问 Grafana:
    • 访问地址:http://<PUBLIC_IP_OF_YOUR_VM>:3000
    • 默认用户名密码为 admin / admin,请修改密码

Elasticsearch Deployment

  1. 为 Elasticsearch 创建数据持久化目录和配置文件目录,并授予所有用户读写权限:
    mkdir -p /srv/elasticsearch/data /srv/elasticsearch/config
    chmod -R a+rw /srv/elasticsearch
  2. /srv/elasticsearch/config/ 目录下创建 elasticsearch.yml 配置文件:
    cat >>> /srv/elasticsearch/config/elasticsearch.yml << EOF
    network.host: 0.0.0.0
    node.name: single-node
    cluster.name: es-docker-cluster
    path.data: /usr/share/elasticsearch/data
    path.logs: /usr/share/elasticsearch/logs
    discovery.type: single-node
    bootstrap.memory_lock: true
    EOF
  3. 使用以下命令启动 Elasticsearch,并绑定数据目录和配置文件:
    docker run -itd --restart always --name es \
      -p 8080:9200 \
      -e "xpack.security.enabled=true" \
      -e "ELASTIC_USERNAME=elastic" \
      -e "ELASTIC_PASSWORD=PassWord" \
      -e "ES_JAVA_OPTS=-Xms4g -Xmx4g" \
      -v /srv/elasticsearch/data:/usr/share/elasticsearch/data \
      -v /srv/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro \
      docker.elastic.co/elasticsearch/elasticsearch:8.17.0
  4. 访问测试:
    curl -u elastic:PassWord http://localhost:8080

    得到如下内容,表示 Elasticsearch 运行正常:

    {
        "name": "single-node",
        "cluster_name": "es-docker-cluster",
        "cluster_uuid": "oO3mfjYWTZ6VZFSClDiSLA",
        "version": {
            "number": "8.17.0",
            "build_flavor": "default",
            "build_type": "docker",
            "build_hash": "2b6a7fed44faa321997703718f07ee0420804b41",
            "build_date": "2024-12-11T12:08:05.663969764Z",
            "build_snapshot": false,
            "lucene_version": "9.12.0",
            "minimum_wire_compatibility_version": "7.17.0",
            "minimum_index_compatibility_version": "7.0.0"
        },
        "tagline": "You Know, for Search"
    }