This project demonstrates how to monitor GitHub and GitLab repositories using Grafana. It provides insights into repository activity, including commits, pull requests, and issues, helping teams better manage their projects.
- Monitor GitHub and GitLab repositories.
- Visualize metrics such as commits, pull requests, and issues.
- Customizable dashboards to focus on specific metrics.
- Real-time data updates for ongoing project management.
- Grafana: For visualizing repository metrics.
- GitHub/GitLab: Source code management platforms.
- Cloud Provider: (AWS) for hosting the virtual machine.
-
Instance Name: Server
-
Amazon Server Image: Ubuntu Server 24.04 LTS (HVM), SSD Volume Type (Free tier).
-
Instance Type: t2.micro
-
Key Pair: Create a new key pair (e.g.,
project_access_key
). -
Network Settings: Create a new security group (e.g.,
Demoproject
). -
Security Group Permissions:
-
Storage: 25GB
-
Launch the instance.
- Download MobaXterm to connect to the EC2 instance.
- Use the EC2 instance's public IP address and add the public key (e.g.,
project_access_key
). - Update the Ubuntu machine:
sudo apt-get update
Ensure that your system has the required dependencies by running the following command:
sudo apt-get install -y software-properties-common
To enable the official Grafana repository, use the following command:
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
Next, download and add the Grafana GPG key to authenticate the packages:
sudo wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
After adding the repository, update your package list and install Grafana:
sudo apt-get update
sudo apt-get install grafana
Start the Grafana server and enable it to run at startup:
sudo /bin/systemctl start grafana-server
Once Grafana is running, you can access the Grafana web interface by navigating to:
http://localhost:3000
(ex.http://52.70.170.54:3000/)
- Username: admin
- Password: admin
Follow these steps to generate a GitHub Personal Access Token (PAT) that you can use for authenticating with GitHub APIs, pushing/pulling code, and managing repositories:
- Go to GitHub and log in with your account credentials.
- In the top-right corner of any GitHub page, click on your profile picture.
- Select Settings from the dropdown.
- Scroll down on the left sidebar and click Developer settings.
- Under Developer settings, click on Personal access tokens.
- Choose Tokens (classic) for general access, or Fine-grained tokens for more granular control (currently in beta).
- Click the Generate new token button.
- Note: Provide a meaningful description for your token (e.g., "Access to XYZ repository").
- Expiration: Optionally set an expiration date (7 days, 30 days, 60 days, 90 days, or no expiration).
Select the appropriate scopes accourding to Project need like this :
- Scroll down and click the Generate token button.
- GitHub will display the token once, so make sure to copy it immediately.
- Store the token securely in a password manager or any secure location. You cannot view this token again once you leave the page.
Go to the Connections section in Grafana and click on Data Sources.
Search for the GitHub data source plugin in the plugin list and install it.
After installing the GitHub data source plugin, select it from the list. Then, configure it by providing a GitHub Personal Access Token (PAT) to allow Grafana to access GitHub repository data.
Once the GitHub data source is configured with the access token, click Save & Test to verify the connection.
Go to Google and search for:
gitlab data source grafana dashboard
You can use a pre-built Grafana dashboard for the GitLab data source to visualize GitLab metrics. Check out the dashboard here:
GitLab Data Source Grafana Dashboard link
In Grafana, go to the Import section and paste the dashboard template code.
Paste the copied dashboard template code and click Load.
Give the Grafana dashboard a name and select the GitHub data source option that you previously configured.
Change the organization (your GitHub username), choose the repository you want to analyze, and set the branch to main. See the image below for guidance.
After setting up the GitHub or GitLab data source and configuring the dashboard, you should see the visualized metrics as shown below.
Thank you for reading my README file!
Feel free to connect with me:
- LinkedIn: Anil Rupnar
- Email: anilrupnar2003@gmail.com