Utility to generate a Prometheus data source text file for your GitLab repository using the GitLab Language API
Project description
gitlab_languages
Utility to generate a Prometheus data source text file for your GitLab instance using the GitLab Language API
installation
-
Install pipenv
pip install pipenv
-
Install python dependencies
pipenv install pipenv shell
-
Set the required environment variables
export GITLAB_ACCESS_TOKEN=<SOME_TOKEN_WITH_API_SCOPE> export GITLAB_URL=https://gitlab.com
-
Run the script
python gitlab_languages.py
usage
usage: gitlab_languages [-h] [--projectlimit PROJECTLIMIT]
[--args ARGS [ARGS ...]]
[--groups GROUPS [GROUPS ...]]
[--ignore_groups IGNORE_GROUPS [IGNORE_GROUPS ...]]
optional arguments:
-h, --help show this help message and exit
--projectlimit PROJECTLIMIT
Set project limit to scan
--args ARGS [ARGS ...]
Provide custom args to the GitLab API
--groups GROUPS [GROUPS ...]
Scan only certain groups
--ignore_groups IGNORE_GROUPS [IGNORE_GROUPS ...]
Ignore certain groups and their projects
additional arguments
You can specify additional arguments, that will be directly supplied to the python-gitlab library or to the GitLab API endpoint. Example:
python3 gitlab_languages --args owned=True
More info about the available additional args can be found here:
example output
The output will look something like this:
metrics.txt
# HELP total_unknown_languages Unknown languages
# TYPE total_unknown_languages gauge
total_unknown_languages 0.0
# HELP Python Python
# TYPE Python gauge
Python 21.790000000000003
# HELP CSS CSS
# TYPE CSS gauge
CSS 8.503333333333334
# HELP SaltStack SaltStack
# TYPE SaltStack gauge
SaltStack 1.95
# HELP JavaScript JavaScript
# TYPE JavaScript gauge
JavaScript 0.9533333333333333
# HELP PLpgSQL PLpgSQL
# TYPE PLpgSQL gauge
PLpgSQL 0.7666666666666666
# HELP Mako Mako
# TYPE Mako gauge
Mako 0.03333333333333333
# HELP Shell Shell
# TYPE Shell gauge
Shell 0.03
# HELP Java Java
# TYPE Java gauge
Java 30.776666666666667
# HELP HTML HTML
# TYPE HTML gauge
HTML 1.8666666666666665
# HELP Arduino Arduino
# TYPE Arduino gauge
Arduino 33.333333333333336
# HELP total_languages_scanned Total languages scanned
# TYPE total_languages_scanned gauge
total_languages_scanned 10.0
# HELP total_projects_scanned Total projects scanned
# TYPE total_projects_scanned gauge
total_projects_scanned 3.0
# HELP total_projects_skipped Total projects skipped
# TYPE total_projects_skipped gauge
total_projects_skipped 7.0
# HELP total_groups_scanned Total groups scanned
# TYPE total_groups_scanned gauge
total_groups_scanned 0.0
Run the script via GitLab API with schedules. Then you can add it to your Prometheus instance as data source.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gitlab_languages-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f3e523932a6a8f0fc7ea255c632f0fe207832902d860f35213a4d4b790f2e0 |
|
MD5 | 721b5f721c170815b6de8c0a0509b1be |
|
BLAKE2b-256 | 88ce8edc7d59427a8160ce5dc7299a06ed9f580aa2d4acb2404a480a95f57d40 |