Exposes basic metrics for your repositories from the GitHub API, to a Prometheus compatible endpoint.
This exporter is setup to take configuration through environment variables. All variables are optional:
All targets support arrays of values (comma delimited). e.g. "org1/repo1, org2/repo3".
ORGSIf supplied, the exporter will enumerate all repositories for any organizations are processed.USERSIf supplied, the exporter will enumerate all repositories for that users in a similar fashion to organisations.REPOSIf supplied, allows you to explicitly set the repos you wish to monitor Can be across different Github users/orgs.
Either through environmental variables or passed in through a token file (more secure).
GITHUB_TOKENIf supplied, enables the user to supply a github authentication token that allows the API to be queried more often. Optional, but recommended.GITHUB_TOKEN_FILEIf supplied instead ofGITHUB_TOKEN, enables the user to supply a path to a file containing a github authentication token that allows the API to be queried more often. Optional, but recommended.
OPTIONAL_METRICSallows you to specify additional collection of the following metrics per repository;
- Commits
- Releases
- Pulls
Please be aware the above metrics can only be collected from the V3 API on a per repositry basis. As a result they are very expensive to capture and you may exceed the GitHub API rate limits if you're monitoring hundreds of repositories.
In order to collect any of the above, populate the OPTIONAL_METRICS variable with a comma delimited set of metrics you wish to capture, e.g. OPTIONAL_METRICS="commits, releases, pulls".
Likely something most users will leave as the default, feel free to override as you see fit.
API_URLGithub API URL, shouldn't need to change this. Defaults tohttps://api.github.comLISTEN_PORTThe port you wish to run the container on, the Dockerfile defaults this to9171METRICS_PATHthe metrics URL path you wish to use, defaults to/metricsLOG_LEVELThe level of logging the exporter will run with, defaults todebug
Run manually from Docker Hub:
docker run -d --restart=always -p 9171:9171 -e REPOS="infinityworks/policies, infinityworks/prom-conf" infinityworks/github-exporter
Build a docker image:
docker build -t <image-name> .
docker run -d --restart=always -p 9171:9171 -e REPOS="infinityworks/policies, infinityworks/prom-conf" <image-name>
github-exporter:
tty: true
stdin_open: true
expose:
- 9171
ports:
- 9171:9171
image: infinityworks/github-exporter:latest
environment:
- REPOS=<REPOS you want to monitor>
- GITHUB_TOKEN=<your github api token>
Metrics will be made available on port 9171 by default. An example of these metrics can be found in the METRICS.md markdown file in the root of this repository
There is a set of blackbox behavioural tests which validate metrics endpoint in the test directory.
Run as follows
make testOnce a new pull request has been merged into master the following script should be executed locally. The script will trigger a new image build in docker hub with the new image having the tag release-<version>. The version is taken from the VERSION file and must follow semantic versioning. For more information see semver.org.
Prior to running the following command ensure the number has been increased to desired version in VERSION:
./release-version.sh