Monitor your GitHub Repos with Docker and Prometheus

Monitor your GitHub Repos with Docker and Prometheus

GitHub is full of great code, information, and interesting statistics. GitHub repositories are full of statistics that make perfect candidates to graph with Grafana. The best way to graph this data is of course with Docker and Prometheus.

Prometheus contains an impressive list of Exporters. These Exporters range from APIs to IoT. They can also integrate with Prometheus and Grafana which produce some beautiful graphs.

Docker, Prometheus, and Grafana

My base setup for anything monitoring related is the Docker, Prometheus, and Grafana stack. This is the baseline I work from and add components like Exporters. I have created the GitHub-Monitoring Repo. This contains a Docker compose file which makes this stack simplified and easy to start.

Getting Started

Prerequisite Ensure you have a Docker host running the latest versions of Docker engine and compose. If you are running Docker for Mac/Windows you are already set. Next, clone the GitHub-Monitoring project to your Docker machine.

We can start configuring the project based on your requirements. If you need to track additional Exporters or targets then edit the Prometheus Targets section located in the static configs section at the end of the file. The Exporter uses the name metrics with port 9171.

     - targets: ['node exporter:9100','localhost:9090', 'metrics:9171']


Create a GitHub token to use for this project. This prevents us from hitting API limits imposed by GitHub for non-authenticated traffic.

Navigate to Create GitHub Token where we will create a token for this project.

  • Provide the token a description.
  • Select scopes, our project only requires the repo permissions.
  • Click the generate token button
  • Copy the token ID and store in a safe place. This is the equivalent of a password so don't store in a public place

GitHub Token

Edit the docker-compose.yml file with your favorite editor. Scroll to the end of the file where you will find the metricsservice section.

First, replace the GITHUB_TOKEN=<GitHub API Token see README>with the token you generated earlier. Next, replace the REPOS with your desired REPOS with which you want to track. In my example I have selected the Docker and freeCodeCamp REPOS as they offer lots of movement and stats.

  tty: true
  stdin_open: true
   - 9171
 image: infinityworks/github-exporter:latest 
  - REPOS=freeCodeCamp/freeCodeCamp,docker/docker
  - GITHUB_TOKEN=<GitHub API Token see README>
  - back-tier

Once configurations are complete let's start it up. From the /github-monitoring project directory run the following command:

$ docker-compose up

That's it. docker-compose builds the entire Grafna and Prometheus stack automagically. The compose file also connects the new GitHub Exporter to our baseline stack. I have elected to run docker-compose without the -d flag initially. This makes it easier for troubleshooting to see logs printed to the terminal.

The Grafana Dashboard is now accessible via: http://<Host IP Address>:3000 for example http://localhost:3000

username - admin
password - foobar (The password is in the config.monitoring env file)

Post Configuration

Now we need to create the Prometheus Datasource to connect Grafana to Prometheues

  • Click the Grafana Menu at the top left corner (looks like a fireball)
  • Click Data Sources
  • Click the green button Add Data Source.
![Add Grafana Data Source](/content/images/2017/02/Grafana_Add_Data_Source-1.png)

Install Dashboard

I created a Dashboard template which is available on GitHub Stats Dashboard. Download the dashboard and select from the Grafana menu -> Dashboards -> Import

This dashboard is a starting point to help you get started with graphing your GitHub Repos. If you have any changes you would like to see in the Dashboard let me know so I can update Grafana site as well.

GitHub Grafana Dashboard


Prometheus in combination with Docker is a powerful yet simple to manage. The GitHub Exporter is one of the many amazing Exporters available to Prometheus. The next few articles I will select several more Exporters to show how easy they are to connect and graph data. Stay tuned.

Follow me

If you liked this article be sure to Follow Me on Twitter to stay updated!