Prometheus exporter for Github rate-limits API
Project description
github-rate-limits-exporter
Prometheus exporter to monitor the Github API rate-limits.
Introduction
If you have ever tried using Github's API, you have probably already run into Github's rate limiting errors.
Without authorization, Github only allows 60 requests per hour (!!), and after creating and using your
own personal access token, you are upgraded to 5000 requests per hour.
That rate limit can be easily reached in just a few minutes by calling the API to list basic information from a medium
sized repository and you would have to wait 50+ minutes for the rate limit to reset in order to continue or try again.
You can up the rate limit to 15,000 with an enterprise account but the problem remains the same:
If your service/program needs to make consistent and/or sustained requests to Github's APIs,
you will have to work around and make the most of Github's rate limits.
So, the Prometheus Github rate-limits exporter was introduced to expose the remaining, used and limit
(quotas) information per Github API as metrics in order to create alerting events and (Grafana) monitoring dashboards.
For the exporter to fetch and expose the Github API rate-limits, you need to supply:
As standalone Python command line tool (pypi)
Install the distribution through PYPI:
pip3 install github-rate-limits-exporter
./github-rate-limits-exporter --help
Tox (wrapper)
Clone the repository and install tox
:
pip install --user tox
Run as PAT
Github authentication type
tox -e run -- \
--github-auth-type pat \
--github-account my_account_name \
--github-token my_token
Run as APP
(Github App) Github authentication type
tox -e run -- \
--github-auth-type app \
--github-account my_account_name \
--github-app-id my_app_id \
--github-app-installation-id my_installation_id \
--github-app-private-key-path /path/to/private_key.pem
Docker
Clone the repositroy and build the docker container image:
docker build -t prometheus-gh-rate-limit-exporter:latest .
Run as PAT Github authentication type
docker run -p 10050:10050 -d \
--name gh-rt-exporter \
-e GITHUB_ACCOUNT=my_account_name \
-e GITHUB_AUTH_TYPE=pat \
-e GITHUB_TOKEN=my_token \
prometheus-gh-rate-limit-exporter:latest
Run as APP (Github App) Github authentication type
docker run -p 10050:10050 -d \
--name gh-rt-exporter \
-e GITHUB_AUTH_TYPE=app \
-e GITHUB_ACCOUNT=my_account_name \
-e GITHUB_APP_ID=111111 \
-e GITHUB_APP_INSTALLATION_ID=22222222 \
-e GITHUB_APP_PRIVATE_KEY_PATH=/app/key.pem \
--mount type=bind,source=/ws/key.pem,target=/app/key.pem,readonly \
prometheus-gh-rate-limit-exporter:latest
Docker-Compose
Another way to test and observe the exporter is through the Prometheus/Grafana/AlertManager
stack on top of the docker-compose:
Clone the repository and install tox
tool:
pip install --user tox
Run as PAT Github authentication type
export GITHUB_AUTH_TYPE=pat
export GITHUB_TOKEN=your_token
export GITHUB_ACCOUNT=your_account
export GF_SECURITY_ADMIN_USER=username
export GF_SECURITY_PASSWORD=password
tox -e dc-run
Run as APP (Github App) authentication type
export GITHUB_AUTH_TYPE=app
export GITHUB_APP_ID=12345
export GITHUB_APP_INSTALLATION_ID=123456
export GITHUB_APP_SRC_PRIVATE_KEY_PATH=/ws/private_key.pem
export GITHUB_APP_PRIVATE_KEY_PATH=/tmp/private_key.pem
export GF_SECURITY_ADMIN_USER=username
export GF_SECURITY_PASSWORD=password
tox -e dc-run
Connect to Prometheus, Grafana and AlertManager:
See also the existing examples:
Cleanup/teardown the composed services
tox -e dc-clean
Other Projects
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for github_rate_limits_exporter-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afe2939fa0c520713e6ed42324d215c82b6b0fc3c6d21b2264584cf8bfe0a3c1 |
|
MD5 | f8f21f0c3f5bb3a5c8b50bddf78d8895 |
|
BLAKE2b-256 | d0b4887cf9a50f304fe308b84e23dea65e037d0bed6f9e340b2fbf822d9dcb1b |