In this article I will show how to monitor Jenkins pipeline jobs status by Prometheus and Grafana Dashboard.

Required Tools :

1.Prometheus (version : 2.8.1)
2.Jenkins (version: 2.176)
3.Jenkins Prometheus Metrics Plugin (version : 2.0.6)
4.Grafana (version: 6.3.3)


1.Prometheus :

Prometheus is an open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

To install Prometheus use below link,

https://www.devopsart.com/2019/09/prometheus-latest-version-installation.html

Configure Prometheus to scrape metrics from Jenkins, use the below configuration in prometheus.yml.

#vi /etc/prometheus/prometheus.yml

# Global config
global:
  scrape_interval:     15s 
  evaluation_interval: 15s 
  scrape_timeout: 15s  

scrape_configs:
    - job_name: 'jenkins'
    metrics_path: /prometheus
   
    static_configs:
    - targets: ['Jenkins IP:Jenkins Port']   #[192.168.56.101:8080]

Save and exit.

Then restart Prometheus service,check the status and verify Prometheus service is running fine.

You can access the Prometheus Web Interface from "http://Jenkins_server_IP:9090/graph"

2.Jenkins :

Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purpose that allows you to build pipelines to automate the process of building, testing and deploying applications.

To install Jenkins use this below link,

https://www.devopsart.com/2019/09/jenkins-installation-and-configuration.html

I have a running Jenkins which has few test pipelines.



4.Jenkins Prometheus Metrics Plugin:

It will expose the Jenkins metrics in Prometheus.

To install this plugin,

Login to Jenkins > manage jenkins > manage plugins >  Available > then search for "Prometheus metrics plugin"  then install it.

Now after installation we need to configure the Prometheus details in Jenkins.

Login to Jenkins > manage Jenkins > Configure Systems > Go to Prometheus section to fill the details like below,


Then save the configuration.

You can see the output of this plugin through this URL "http://Jenkins_server_IP:Jenkins Port/prometheus"

3.Grafana :

Grafana is an open-source platform for data visualization, monitoring,Alerting and analysis.

To install Grafana use this below link,

https://www.devopsart.com/2019/09/grafana-installation-and-configuration.html

Next we need to configure Prometheus in Grafana data-sources.

Login to Grafana > Go to configuration > Choose data source > Add data source > select Prometheus > Enter the Prometheus server details,

Once given the details click "Save & Test", it should say Data Source is working like below image,

Now come to Grafana home page and click "+" button which is in left side and click import.

There are few Jenkins dashboard are available already the IDs are 9964, 960 and my Jenkins Dashboard JSON download url is, link

My Jenkins Dashboard,





In this Dashboard, you can see total pipelines, Last build status, Job Duration,etc.

That's it, We have successfully configured Jenkins with Prometheus and Grafana Dashboard, Now we can visualize the Jenkins activities and data in Grafana.

4 Comments

  1. Great article. Why is the CPU usage 0.050%?

    ReplyDelete
  2. I downloaded your json file and tried to get similar dashboard for my local jenkins. But there is no data coming inside panel. All the panels are blank. But i see the data present in prometheus.
    Grafana Version : Open Source v7.0.0
    Prometheus Version : 2.18.1

    ReplyDelete
    Replies
    1. Check the datasource status and in the panel check which datasource is selected.

      Delete

Post a Comment

Previous Post Next Post