Categorygithub.com/bossm8/gitlab-pages-exporter
repositorypackage
0.0.0-20241219083421-a3248711629e
Repository: https://github.com/bossm8/gitlab-pages-exporter.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

GitLab Pages Exporter (gpe)

Exporter gathering periodic statistics about GitLab pages via GitLab's API.

Why This Exporter Exists

There is no builtin way in GitLab to find information about what projects expose pages.

How it Works

The exporter periodically scrapes the GitLab API to get information about pages deployments. Since there is no built-in way in GitLab to get all projects with pages deployments the exporter checks if a project has CI/CD enabled and if so if there is a job named pages which was successfully run. If those conditions are met, the exporter assumes pages are deployed.

GitLab Pages Doc

Note: Scraping may issue a lot of requests depending on how large your instance is and you might need to check your rate-limiting settings.

Exposed Metrics

The following metrics will be exposed to :2112/metrics:

Metric NameDescription
gpe_project_pages_enabledIf GitLab pages are enabled
gpe_project_pages_totalTotal number of projects with deployed pages
gpe_custom_domains_verifiedIf a custom Domain is verified
gpe_custom_domains_totalTotal number of custom domains registered
gpe_projects_checked_totalNumber of projects processed
gpe_check_runningIf the check is currently running
gpe_last_check_duration_secondsHow long the last check took
gpe_last_check_run_finished_secondsWhen the last check happened
gpe_next_check_run_scheduled_secondsWhen the next check will happen
gpe_number_of_scrapesHow many times the exporter ran since restart

Configuration

Currently configuration can only be achieved with environment variables, it is recommended to use the docker image to run the exporter.

Variable NameDescriptionDefault
GPE_GITLAB_ADMIN_READ_TOKENA read-only API token with admin permissions (to be able to fetch all projects).``
GPE_GITLAB_API_URLThe base URL to your GitLab instance.``
GPE_CRON_SCHEDULESchedule for tests in cron format (seconds, minutes, hours, day of month, month, day of week).0 0 2 * * *
GPE_SET_ALL_PROJECT_METRICSIf all projects should be exposed as metric, by default only project with pages deployed are exposed. Only set to true if really needed as this grows quick!false

Example usage:

docker run -it --rm \
           -e GPE_GITLAB_ADMIN_READ_TOKEN=<TOKEN> \
           -e GPE_GITLAB_API_URL=<URL> \
           -e TZ=Europe/Zurich \
           -p 2112:2112 \
           ghcr.io/bossm8/gitlab-pages-exporter:latest

Grafana Dashboards

Find an example dashboard in the grafana folder.

Credits

Originally developed at Bern University of Applied Sciences (TI): BFH