{"id":16825075,"url":"https://github.com/max-wittig/gitlab-languages","last_synced_at":"2025-03-17T04:31:23.361Z","repository":{"id":83679479,"uuid":"136232448","full_name":"max-wittig/gitlab-languages","owner":"max-wittig","description":"Utility to generate a Prometheus exporter text file for your GitLab repository using the GitLab Language API","archived":false,"fork":false,"pushed_at":"2024-07-06T02:05:04.000Z","size":239,"stargazers_count":14,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-13T11:13:02.771Z","etag":null,"topics":["api","gitlab","grafana","language","prometheus","python","python-gitlab"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/max-wittig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-05T20:41:16.000Z","updated_at":"2024-05-21T08:55:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"87da45b4-683e-4737-9bec-4334a30f9940","html_url":"https://github.com/max-wittig/gitlab-languages","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":0.3513513513513513,"last_synced_commit":"050d63b6fc155b1ea37107d0764b0b9ece6c758b"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-wittig%2Fgitlab-languages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-wittig%2Fgitlab-languages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-wittig%2Fgitlab-languages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max-wittig%2Fgitlab-languages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/max-wittig","download_url":"https://codeload.github.com/max-wittig/gitlab-languages/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221671754,"owners_count":16861305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","gitlab","grafana","language","prometheus","python","python-gitlab"],"created_at":"2024-10-13T11:12:49.971Z","updated_at":"2024-10-27T11:55:41.439Z","avatar_url":"https://github.com/max-wittig.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gitlab-languages\n\n[![PyPI - License](https://img.shields.io/pypi/l/gitlab-languages.svg)](https://github.com/max-wittig/gitlab-languages/blob/master/LICENSE)\n\nUtility to generate a Prometheus data source text file for your GitLab instance\nusing the [GitLab Language API](https://docs.gitlab.com/ee/api/projects.html#languages)\n\n## installation from PyPI\n\n1. Install from PyPI as CLI\n\n   ```bash\n   pip install -U gitlab-languages\n   ```\n\n1. Run the program\n\n   ```bash\n   gitlab-languages --cache cache.json --args owned=True # more info about usage: see below\n   ```\n\n## installation from source\n\n1. Install python dependencies\n\n    ```bash\n    poetry install\n    ```\n\n1. Set the required environment variables\n\n    ```bash\n    export GITLAB_TOKEN=\u003cSOME_TOKEN_WITH_API_SCOPE\u003e\n    export GITLAB_URL=https://gitlab.com # optional, defaults to https://gitlab.com\n    # optional:\n    export WORKER_COUNT=24\n    ```\n\n1. Run the tool\n\n    ```bash\n    gitlab-languages\n    ```\n\n## usage\n\n```plain\nusage: gitlab_languages [-h] [--project_limit PROJECT_LIMIT]\n                        [--args ARGS [ARGS ...]]\n                        [--groups GROUPS [GROUPS ...]]\n                        [--ignore_groups IGNORE_GROUPS [IGNORE_GROUPS ...]]\n                        [--cache CACHE] [-o OUTPUT]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --project_limit PROJECT_LIMIT\n                        Set project limit to scan\n  --args ARGS [ARGS ...]\n                        Provide custom args to the GitLab API\n  --groups GROUPS [GROUPS ...]\n                        Scan only certain groups\n  --ignore_groups IGNORE_GROUPS [IGNORE_GROUPS ...]\n                        Ignore certain groups and their projects\n  --cache CACHE         Cache file to use\n  -o OUTPUT, --output OUTPUT\n                        Location of the metrics file output\n```\n\n### additional arguments\n\nYou can specify additional arguments, that will be directly supplied to the\n[python-gitlab library](https://github.com/python-gitlab/python-gitlab) or to the GitLab API endpoint.\nExample:\n\n```bash\ngitlab-languages --args owned=True\n```\n\nMore info about the available additional args can be found here:\n\n* http://python-gitlab.readthedocs.io/en/stable/\n* https://docs.gitlab.com/ee/api/\n\n### example output\n\nThe output will look something like this:\n\n```plain\nmetrics.txt\n\n# HELP languages_percent Languages scanned in percent\n# TYPE languages_percent gauge\nlanguages_percent{language=\"Java\"} 11.73\nlanguages_percent{language=\"CSS\"} 1.97\nlanguages_percent{language=\"TypeScript\"} 3.5\nlanguages_percent{language=\"HTML\"} 6.14\nlanguages_percent{language=\"JavaScript\"} 17.16\nlanguages_percent{language=\"Python\"} 10.4\nlanguages_percent{language=\"Modelica\"} 3.7\nlanguages_percent{language=\"TeX\"} 1.64\nlanguages_percent{language=\"Shell\"} 6.35\nlanguages_percent{language=\"Batchfile\"} 0.76\nlanguages_percent{language=\"HCL\"} 7.15\nlanguages_percent{language=\"BitBake\"} 0.56\nlanguages_percent{language=\"C\"} 5.25\nlanguages_percent{language=\"C++\"} 0.72\nlanguages_percent{language=\"Matlab\"} 2.77\nlanguages_percent{language=\"TXL\"} 0.05\nlanguages_percent{language=\"Objective-C\"} 1.48\nlanguages_percent{language=\"XSLT\"} 1.68\nlanguages_percent{language=\"Perl\"} 1.71\nlanguages_percent{language=\"Ruby\"} 0.03\nlanguages_percent{language=\"C#\"} 10.3\nlanguages_percent{language=\"PowerShell\"} 0.11\nlanguages_percent{language=\"Pascal\"} 0.01\nlanguages_percent{language=\"ASP\"} 0.0\nlanguages_percent{language=\"PLpgSQL\"} 0.0\nlanguages_percent{language=\"Makefile\"} 2.06\nlanguages_percent{language=\"SQLPL\"} 0.0\nlanguages_percent{language=\"Puppet\"} 0.0\nlanguages_percent{language=\"Groovy\"} 2.56\nlanguages_percent{language=\"M4\"} 0.01\nlanguages_percent{language=\"Roff\"} 0.15\nlanguages_percent{language=\"CMake\"} 0.01\nlanguages_percent{language=\"NSIS\"} 0.01\nlanguages_percent{language=\"PHP\"} 0.0\nlanguages_percent{language=\"Go\"} 0.0\nlanguages_percent{language=\"Smalltalk\"} 0.02\nlanguages_percent{language=\"Visual Basic\"} 0.0\nlanguages_percent{language=\"Smarty\"} 0.0\n# HELP languages_scanned_total Total languages scanned\n# TYPE languages_scanned_total gauge\nlanguages_scanned_total 38.0\n# HELP projects_scanned_total Total projects scanned\n# TYPE projects_scanned_total gauge\nprojects_scanned_total 61.0\n# HELP projects_skipped_total Total projects skipped\n# TYPE projects_skipped_total gauge\nprojects_skipped_total 0.0\n# HELP projects_no_language_total Projects without language detected\n# TYPE projects_no_language_total gauge\nprojects_no_language_total 39.0\n# HELP groups_scanned_total Total groups scanned\n# TYPE groups_scanned_total gauge\ngroups_scanned_total 0.0\n```\n\nRun the script via GitLab CI with schedules and export the metrics.txt file as GitLab pages.\nThen you can add it to your Prometheus instance as scrape source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax-wittig%2Fgitlab-languages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmax-wittig%2Fgitlab-languages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax-wittig%2Fgitlab-languages/lists"}