Package: github-rate-limits-exporter
github-rate-limits-exporterPrometheus exporter to monitor the Github API rate-limits.IntroductionIf you have ever tried using Github's API, you have probably already run into Github's rate limiting errors.Without authorization, Github only allows60 requests per hour(!!), and after creating and using yourown personal access token, you are upgraded to5000 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 mediumsized repository and you would haveto wait 50+ minutesfor the rate limit to reset in order to continue or try again.You can up the rate limit to15,000with 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, thePrometheus Github rate-limits exporterwas introduced to expose theremaining,used,limit(quotas) andreset(rate-limit window resets in UTC seconds) information per Github API as metrics in orderto create alerting events and (Grafana) monitoring dashboards.For the exporter to fetch and expose the Github API rate-limits, you need to supply:aGitHub Personal Access Token (PAT)orGitHub App (APP) credentials.As standalone Python command line tool (pypi)Install the tool throughpypi:pip3installgithub-rate-limits-exporter
./github-rate-limits-exporter--helpTox (wrapper)Clone the repository and installtox:pipinstall--usertoxRun asPATGithub authentication typetox-erun-exporter--\--github-auth-typepat\--github-accountmy_account_name\--github-tokenmy_tokenRun asAPP(Github App) Github authentication typetox-erun-exporter--\--github-auth-typeapp\--github-accountmy_account_name\--github-app-idmy_app_id\--github-app-installation-idmy_installation_id\--github-app-private-key-path/path/to/private_key.pemDockerClone the repositroy and build the docker container image:dockerbuild-tprometheus-gh-rate-limit-exporter:latest.or pull directly fromDocker Hub:dockerpulltheodore86/prometheus-gh-rate-limit-exporter:latestRun as PAT Github authentication typedockerrun-p10050:10050-d\--namegh-rl-exporter\--restarton-failure\-eGITHUB_ACCOUNT=my_account_name\-eGITHUB_AUTH_TYPE=pat\-eGITHUB_TOKEN=my_token\-eEXPORTER_LOG_LEVEL=4\prometheus-gh-rate-limit-exporter:latestRun as APP (Github App) Github authentication typedockerrun-p10050:10050-d\--namegh-rl-exporter\--restarton-failure\-eGITHUB_AUTH_TYPE=app\-eGITHUB_ACCOUNT=my_account_name\-eGITHUB_APP_ID=111111\-eGITHUB_APP_INSTALLATION_ID=22222222\-eGITHUB_APP_PRIVATE_KEY_PATH=/app/key.pem\-eEXPORTER_LOG_LEVEL=4\--mounttype=bind,source=/ws/key.pem,target=/app/key.pem,readonly\prometheus-gh-rate-limit-exporter:latestDocker-ComposeAnother way to test and observe the exporter is through thePrometheus/Grafana/AlertManagerstack on top of thedocker-compose:Clone the repository and installtoxtool:pipinstall--usertoxRun as PAT Github authentication typeexportGITHUB_AUTH_TYPE=patexportGITHUB_TOKEN=your_tokenexportGITHUB_ACCOUNT=your_accountexportEXPORTER_LOG_LEVEL=4exportGF_SECURITY_ADMIN_USER=usernameexportGF_SECURITY_PASSWORD=password
tox-edc-runRun as APP (Github App) authentication typeexportGITHUB_ACCOUNT=your_accountexportGITHUB_AUTH_TYPE=appexportGITHUB_APP_ID=12345exportGITHUB_APP_INSTALLATION_ID=123456exportGITHUB_APP_SRC_PRIVATE_KEY_PATH=/ws/private_key.pemexportGITHUB_APP_PRIVATE_KEY_PATH=/tmp/private_key.pemexportEXPORTER_LOG_LEVEL=4exportGF_SECURITY_ADMIN_USER=usernameexportGF_SECURITY_PASSWORD=password
tox-edc-runConnect to Portainer management UIPortainer(credentials:admin/adminpassword)Connect to Prometheus, Grafana and AlertManagerPrometheusGrafanaAlertManagerSee also the existing examples:Grafana dashboardsAlertmanager rulesCleanup/teardown the composed servicestox-edc-cleanKubernetes - Helm chartThis helm charthelps to install and configure github-rate-limits exporter on Kubernetes clusters.In order to try out (locally) the chartsInstall the tools:KIND binaryHelmfile binarysudobashkubernetes/prerequisites.shCreate the KIND cluster:kindcreatecluster--namemonitor--configkubernetes/kind.ymlBring up thegithub-rate-limits exporterand the Kubernetes Prometheus stack:exportGITHUB_ACCOUNT=your_accountexportGITHUB_AUTH_TYPE=appexportGITHUB_APP_ID=12345exportGITHUB_APP_INSTALLATION_ID=123456exportGITHUB_APP_SRC_PRIVATE_KEY_PATH=/ws/private_key.pem
helmfile-fkubernetes/helmfile.ymlsyncCleanup/teardown the workloadshelmfile-fkubernetes/helmfile.ymldestroyOther ProjectsGithub Rate Limits Exporter - written in GOReferencescreating-a-personal-access-tokencreating-a-github-appinstalling-github-apps-in-your-organizationinstalling-github-apps-in-your-repositoryhow-to-get-most-out-of-github-api-rate-limits