Monitoring Jenkins with Prometheus and Grafana
The pre-requisites for this project is having Docker and Docker Compose
To setup the project, follow the steps below:
Clone the repository using git:
git clone [email protected]:limebrew-org/jenkins-monitoring.git
-
Setup Jenkins locally using Docker Compose:
docker-compose up -d jenkins
-
Setup the admin password by exec into the docker container or via docker logs
docker exec -it jenkins sh cat /var/jenkins_home/secrets/initialAdminPassword
-
Install the recommended plugins and setup admin password
-
Now once everything is setup, Navigate to
Manage Jenkins
>Plugins
>Available
and then search for the two plugins:
-
Choose the 2 plugins and install and then restart Jenkins once downloaded.
-
Once Jenkins restarts, the logs will be visible at
localhost:8080/prometheus/
- You can configure prometheus by navigating to
Manage Jenkins
>System
>Prometheus
-
Setup prometheus locally using Docker Compose:
docker-compose up -d prometheus
-
Prometheus server will be running at
localhost:9090
- The configuration file for prometheus is available at
./prometheus/prometheus.yml
in the repo.
- The
prometheus.yml
have the configuration to connect to Jenkins via http and listens to the logs atjenkins_ip:8080/prometheus/
N.B. If you already have jenkins running on a remote machine, change in the targets
under static_configs
in ./prometheus/prometheus.yml
- job_name: jenkins
honor_timestamps: true
metrics_path: /prometheus/
follow_redirects: true
static_configs:
- targets:
- jenkins_ip_or_domain_name:8080
-
Setup Grafana locally using Docker Compose:
docker-compose up -d grafana
-
Grafana server will be running at
localhost:3000
-
Authenticate to Grafana via the
username
andpassword
which is set indocker-compose.yml
-
Once done, click on the
Toggle Menu
in the top left corner >Connections
>Datasources
. ThePrometheus Jenkins
data source will be automatically visible. This is done via creating the datasource on container creation process from the grafana config file at./grafana/datasource.yml
-
Now import a public dashboard template from
https://grafana.com/grafana/dashboards/?search=jenkins
You can try the following Dashboard templatesa. Jenkins: Performance and Health Overview: https://grafana.com/grafana/dashboards/9964-jenkins-performance-and-health-overview/ b. https://grafana.com/grafana/dashboards/9524-jenkins-performance-and-health-overview/
Copy the dashboard template ID and paste it during import, then choose the datasource
as Prometheus Jenkins
.
- Once done, you can view the dashboard in Grafana.
- Dont forget to save it in
dashboards
folder insidegrafana