Skip to content

About

Prometheus exporter for GitLab governance, access and project metrics.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

GitLab Prometheus Exporter

GitLab Monitoring

The GitLab Prometheus Exporter is a FastAPI application that exposes GitLab access metrics for Prometheus. It retrieves access data from GitLab and provides it in a format that can be scraped by Prometheus for monitoring purposes.

GitLab Prometheus Exporter

Development

To run the GitLab Prometheus Exporter locally for development, follow these steps:

  1. Clone the repository:

    git clone https://github.com/CodeWithEmad/gitlab-prometheus-exporter.git
    cd gitlab-prometheus-exporter
  2. Create a virtual environment and activate it:

    python -m venv .venv
    source .venv/bin/activate  # On Windows use `.venv\Scripts\activate`
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Set the necessary environment variables.

    • GITLAB_URL URL of the GitLab instance (e.g., "https://gitlab.com")
    • GITLAB_TOKEN Personal access token for GitLab API authentication
    • GITLAB_GROUP_ID ID of the GitLab group to monitor (e.g., "123456")
    • REFRESH_INTERVAL Interval in seconds for refreshing the metrics (default: "300")
    • EXPORTER_PORT Port on which the exporter will run (default: "8000")
    • EXPORTER_USER Username for accessing the exporter (default: "user")
    • EXPORTER_PASS Password for accessing the exporter (default: "pass")
    • LOG_LEVEL Logging level for the application (default: "INFO")
  5. Run the application:

    docker compose up -d

    Alternatively, you can run the application directly using Uvicorn:

    uvicorn app.main:app --host 0.0.0.0 --port 8080

The GitLab Access Exporter will be available at http://localhost:8080/metrics and can be scraped by Prometheus for monitoring GitLab access metrics. Note that when configuring Grafana, you should use http://prometheus:9090 as the Prometheus data source URL if you are running Grafana and Prometheus in Docker containers, as they will be on the same network.

Grafana is up and running at http://localhost:3000 with the default credentials (admin/admin). You can configure Grafana to use Prometheus as a data source and create dashboards to visualize the GitLab access metrics.

After setting up the data source in Grafana, you can import or create dashboards to visualize the metrics collected by the GitLab Access Exporter. Just import the provided Grafana dashboard JSON file in config/grafana-dashboard.json or create your own custom dashboards to monitor GitLab access metrics effectively.

Production Deployment

For production deployment, you can use Docker to containerize the application. There's no Grafana and Prometheus in production deployment; you need to set up your own Prometheus and Grafana instances and configure them to scrape the metrics from the GitLab Access Exporter.

  1. Build the Docker image:

    docker compose build -t gitlab-access-exporter:latest .
  2. Set the necessary environment variables in the docker-compose.yml file or use a .env file to provide the required configuration.

  3. Run the Docker container:

    docker compose up -d

The GitLab Access Exporter will be available at http://localhost:8080/metrics and can be scraped by Prometheus for monitoring GitLab access metrics.

License

This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.

About

Prometheus exporter for GitLab governance, access and project metrics.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages