CLI tool that uploads the Github traffic and statistics API data to influxdb on a daily basis
-
Configure
github_exporter.json
(see the configuration section below). -
Run it.
docker compose up --detach
-
Build the docker image.
docker build . --tag github-exporter
-
Configure
github_exporter.json
(see the configuration section below). -
Run it.
docker run --rm --tty --interactive --read-only --cap-drop ALL --security-opt no-new-privileges:true --cpus 2 -m 64m --pids-limit 16 --volume ./github_exporter.json:/app/github_exporter.json:ro ghcr.io/rare-magma/github-exporter:latest
For convenience, you can install this exporter with the following command or follow the manual process described in the next paragraph.
make build
make install
$EDITOR $HOME/.config/github_exporter.json
-
Build
github_exporter
with:go build -ldflags="-s -w" -o github_exporter main.go
-
Copy
github_exporter
to$HOME/.local/bin/
. -
Copy
github_exporter.json
to$HOME/.config/
, configure them (see the configuration section below) and make them read only. -
Copy the systemd unit and timer to
$HOME/.config/systemd/user/
:cp github-exporter.* $HOME/.config/systemd/user/
-
and run the following command to activate the timer:
systemctl --user enable --now github-exporter.timer
It's possible to trigger the execution by running manually:
systemctl --user start github-exporter.service
The config file has a few options:
{
"InfluxDBHost": "influxdb.example.com",
"InfluxDBApiToken": "ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc2RhCg==",
"Org": "home",
"Bucket": "github",
"GithubApiToken": "ZXhhbXBsZXRva2VuZXhhcXdzZGFzZGptcW9kcXdvZGptcXdvZHF3b2RqbXF3ZHFhc2RhCg=="
}
InfluxDBHost
should be the FQDN of the influxdb server.Org
should be the name of the influxdb organization that contains the github data bucket defined below.Bucket
should be the name of the influxdb bucket that will hold the github data.InfluxDBApiToken
should be the influxdb API token value.- This token should have write access to the
BUCKET
defined above.
- This token should have write access to the
GithubApiToken
should be the Github API token value.- This token should be assigned the "Administration" repository permissions (read) permission.
Check the systemd service logs and timer info with:
journalctl --user --unit github-exporter.service
systemctl --user list-timers
- github_stats_clones: Number of unique git clones and total count per repo
- github_stats_paths: Number of unique views and total count per path in each repo
- github_stats_referrals: Number of unique referrals and total count per repo
- github_stats_views: Number of unique views and total count per repo
- github_stats_stars: Number of stars per repo
- github_stats_forks: Number of forks per repo
github_stats_clones,repo=rare-magma/guitos count=1,uniques=1 1722124800
github_stats_paths,repo=rare-magma/guitos,path=/rare-magma/guitos/blob/main/docs/images/tooltip.png count=2,uniques=1 1723285062
github_stats_referrals,repo=rare-magma/guitos,referrer=github.com count=74,uniques=23 1723285062
github_stats_views,repo=rare-magma/guitos count=1,uniques=1 1723161600
github_stats_stars,repo=rare-magma/guitos count=30 1723285063
github_stats_forks,repo=rare-magma/guitos count=3 1723285063
In github-dashboard.json
there is an example of the kind of dashboard that can be built with github-exporter
data:
Import it by doing the following:
- Create a dashboard
- Click the dashboard's settings button on the top right.
- Go to JSON Model and then paste there the content of the
github-dashboard.json
file.
For convenience, you can uninstall this exporter with the following command or follow the process described in the next paragraph.
make uninstall
Run the following command to deactivate the timer:
systemctl --user disable --now github-exporter.timer
Delete the following files:
~/.local/bin/github_exporter
~/.config/github_exporter.json
~/.config/systemd/user/github-exporter.timer
~/.config/systemd/user/github-exporter.service