Continuous Integration and Monitoring with Jenkins, Prometheus, and Grafana on macOS

Tejaksha K
3 min readMay 21, 2024

--

In modern software development, continuous integration and continuous deployment (CI/CD), along with robust monitoring, are essential practices. Jenkins, Prometheus, and Grafana are three powerful tools that facilitate these practices. This article provides a basic explanation of each tool and guides you through their installation on macOS.

Jenkins

What is Jenkins?

Jenkins is an open-source automation server that helps automate parts of the software development process related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

Key Features of Jenkins

  • Extensibility: Jenkins supports numerous plugins that extend its capabilities.
  • Distributed Builds: Jenkins can distribute builds and tests across multiple machines.
  • Pipeline as Code: Jenkins uses a domain-specific language (DSL) for defining build pipelines.

Basic Installation of Jenkins on macOS

Prerequisites

  • Java Development Kit (JDK) 8 or 11

Steps

  1. Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install Java:

brew install openjdk@11

3. Install Jenkins:

brew install jenkins-lts

4. Start Jenkins:

brew services start jenkins-lts

5.Access Jenkins:

Open your web browser and navigate to http://localhost:8080. Follow the setup instructions provided by Jenkins.

Prometheus

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. It collects and stores metrics as time series data, recording real-time metrics in a highly dimensional data model.

Key Features of Prometheus

  • Multi-dimensional Data Model: With time series data identified by metric name and key/value pairs.
  • Powerful Query Language: PromQL for slicing and dicing data.
  • Efficient Storage: Prometheus stores time series data efficiently.

Basic Installation of Prometheus on macOS

Steps

  1. Install Prometheus using Homebrew:
brew install prometheus

2. Run Prometheus:

brew services start prometheus

3. Access Prometheus:

Open your web browser and navigate to http://localhost:9090.

The default username and password will be admin and admin make sure you change once you login.

Grafana

What is Grafana?

Grafana is an open-source platform for monitoring and observability. It provides tools to turn your time-series database (like Prometheus) data into beautiful graphs and visualizations.

Key Features of Grafana

  • Dashboards: Create, explore, and share dashboards with your team.
  • Plugins: Numerous plugins for data sources, panels, and applications.
  • Alerting: Set up alerts to notify you of any changes or issues in your data.

Basic Installation of Grafana on macOS

Steps

  1. Install Grafana using Homebrew:
brew install grafana

2. Start Grafana:

brew services start grafana

3. Access Grafana:

Open your web browser and navigate to http://localhost:3000. The default login is admin for both username and password.

Integrating Jenkins, Prometheus, and Grafana

Monitoring Jenkins with Prometheus and Grafana

  1. Install Prometheus Plugin in Jenkins:
  • Go to Jenkins Dashboard -> Manage Jenkins -> Manage Plugins.
  • Install the “Prometheus metrics plugin”.

2. Configure the Prometheus Plugin in Jenkins:

  • Go to Jenkins Dashboard -> Manage Jenkins -> Configure System.
  • Find the “Prometheus” section and check “Enable Prometheus Metrics”.

3. Add Jenkins Job Metrics to Prometheus:

Edit the Prometheus configuration file (/usr/local/etc/prometheus.yml or /opt/homebrew/etc/prometheus.yml path ) to scrape Jenkins metrics by adding the following:

scrape_configs:
- job_name: 'jenkins'
static_configs:
- targets: ['localhost:8080']

4. Visualize Jenkins Metrics in Grafana

  • Add Prometheus as a data source in Grafana:
  • Go to Grafana -> Configuration -> Data Sources -> Add data source.
  • Select “Prometheus” and set the URL to http://localhost:9090.
  • Create a new dashboard in Grafana and add panels to visualize Jenkins metrics.

By following these steps, you will have Jenkins for CI/CD, Prometheus for monitoring, and Grafana for visualisation, all set up and integrated on your macOS machine.

--

--

Tejaksha K
Tejaksha K

Written by Tejaksha K

I'm a Full Stack Developer & Cloud Expert with experience in Google Cloud Platform & AWS.

No responses yet