> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitoring with Prometheus Grafana

> Guides installing Jenkins Prometheus plugin, exposing /prometheus metrics, configuring Prometheus and Grafana via Docker Compose, importing dashboards and validating Jenkins monitoring and metrics visualization.

In this lesson you'll learn how to monitor Jenkins by exposing Prometheus-format metrics using the Jenkins "Prometheus metrics" plugin, scraping those metrics with Prometheus, and visualizing them in Grafana. This guide includes configuration examples, a Docker Compose stack for Prometheus + Grafana, Prometheus scrape config, example Prometheus queries, and steps to import a community Jenkins dashboard into Grafana.

What you'll cover:

* Install and configure the Jenkins Prometheus plugin
* Verify the `/prometheus` metrics endpoint
* Run Prometheus and Grafana (Docker Compose)
* Configure Prometheus to scrape Jenkins
* Add Prometheus as a Grafana data source and import a Jenkins dashboard
* Create test Jenkins activity and validate dashboards

Prerequisites

* A running Jenkins instance where you can install plugins and access Manage Jenkins → Configure System
* Docker & Docker Compose (for the Prometheus + Grafana stack example) or an existing Prometheus/Grafana installation
* Network connectivity between Prometheus and Jenkins (or adjust `prometheus.yml` accordingly)

Install the Jenkins Prometheus plugin

1. In Jenkins go to Manage Jenkins → Manage Plugins and install the "Prometheus metrics" plugin.
2. After installation open Manage Jenkins → Configure System to review plugin settings and enable the metric groups you need (JVM, build metrics, node status, disk usage, etc.).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-plugin-page.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=a8448dff825138823d343933cda1ba22" alt="A screenshot of the Jenkins &#x22;Prometheus metrics&#x22; plugin webpage, showing the plugin title, documentation tab, and an About/Metrics Exposed section. On the right are version details, install statistics, and links." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-plugin-page.jpg" />
</Frame>

Configure the Prometheus metrics plugin

* The plugin exposes metrics at `/prometheus` by default.
* Typical settings include the collection interval (often 10s) and checkboxes to enable/disable metric groups (e.g., build durations, JVM metrics).
* Some metrics (like disk usage) may require extra permissions or supplemental plugins.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=82d50197698d02b78f0e8c2c709b946b" alt="A screenshot of a Jenkins &#x22;Manage Jenkins > System&#x22; settings page showing the Prometheus metrics plugin options, including a &#x22;Collecting metrics period in seconds&#x22; field and multiple checked checkboxes for counting build durations. The bottom shows job attribute name input and &#x22;Save&#x22; and &#x22;Apply&#x22; buttons." data-og-width="1920" width="1920" data-og-height="1080" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=280&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=11749058acfaff6cf8fe9dd19d426743 280w, https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=560&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=ce5e74bcbc94566b745f950d5d1b7899 560w, https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=840&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=db9524244494a1f70743fbe80ed858d2 840w, https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=1100&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=3325f0900bbf1996919714fc98697573 1100w, https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=1650&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=03b9cf81dd713f9bb1076648bad938e1 1650w, https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-prometheus-metrics-settings.jpg?w=2500&fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=a4a7fc3d74000ca785d967ab6b50df0b 2500w" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  If the Prometheus plugin requests a Jenkins restart after changing settings, restart Jenkins so the `/prometheus` endpoint is served correctly. The endpoint will be available at `http://<jenkins-host>:<jenkins-port>/prometheus`.
</Callout>

Verify the metrics endpoint
When active, the `/prometheus` endpoint returns plain text in Prometheus exposition format. Example (truncated):

```text theme={null}
# HELP jvm_memory_bytes_used Used bytes of a given JVM memory area.
# TYPE jvm_memory_bytes_used gauge
jvm_memory_bytes_used{area="heap",} 1.051688996E8
jvm_memory_used{area="nonheap",} 1.18338064E8
# HELP jvm_memory_pool_bytes_used Used bytes of a given JVM memory pool.
# TYPE jvm_memory_pool_bytes_used gauge
jvm_memory_pool_bytes_used{pool="Metaspace",} 8.5643168E7
jvm_memory_pool_bytes_used{pool="G1 Old Gen",} 1.02023168E8
# HELP jvm_memory_bytes_committed Committed (bytes) of a given JVM memory area.
# TYPE jvm_memory_bytes_committed gauge
jvm_memory_bytes_committed{area="heap",} 3.5651584E8
```

Run Prometheus + Grafana (example Docker Compose)
This Docker Compose example brings up Prometheus and Grafana. Grafana is configured with `admin` / `password` credentials and is reachable on host port `8081`. Prometheus reads `/etc/prometheus/prometheus.yml` from the `./prometheus` folder.

```yaml theme={null}
version: '3.8'
services:
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    ports:
      - 9090:9090
    restart: unless-stopped
    volumes:
      - ./prometheus:/etc/prometheus
      - prom_data:/prometheus

  grafana:
    image: grafana/grafana
    container_name: grafana
    ports:
      - 8081:3000
    restart: unless-stopped
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=password
    volumes:
      - ./grafana:/etc/grafana/provisioning/datasources

volumes:
  prom_data:
```

Prometheus configuration: `prometheus.yml`
Place this minimal `prometheus.yml` in `./prometheus/prometheus.yml` (update the Jenkins target to your host/IP):

```yaml theme={null}
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    metrics_path: /metrics
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'jenkins'
    metrics_path: /prometheus
    scheme: http
    static_configs:
      - targets: ['64.227.187.25:8080']  # replace with your Jenkins host:port
```

Start the stack

```bash theme={null}
# from the directory containing docker-compose.yml
docker compose up -d
```

Example Docker Compose output:

```text theme={null}
[+] Running 4/4
✔ Network prometheus-grafana_default    Created      0.1s
✔ Volume "prometheus-grafana_prom_data" Created      0.0s
✔ Container prometheus                  Started      0.6s
✔ Container grafana                     Started      0.6s
```

Verify Prometheus is scraping Jenkins

* Open Prometheus at `http://<vm-ip>:9090` (or `http://localhost:9090`).
* Navigate to Status → Targets and confirm the `jenkins` job target is UP and scraping the `/prometheus` path.

Exploring Jenkins metrics in Prometheus
Common metric names exposed by the plugin:

| Metric                          | What it measures                        | Example query                                   |
| ------------------------------- | --------------------------------------- | ----------------------------------------------- |
| `jenkins_job_count_value`       | Total number of jobs                    | `jenkins_job_count_value`                       |
| `jenkins_plugins_active`        | Number of active plugins (gauge)        | `jenkins_plugins_active`                        |
| `jenkins_plugins_withUpdate`    | Plugins with available updates (gauge)  | `jenkins_plugins_withUpdate`                    |
| `jenkins_job_queuing_duration`  | Job queue durations (histogram/summary) | `jenkins_job_queuing_duration{quantile="0.95"}` |
| `jenkins_executor_in_use_value` | Executors currently in use              | `jenkins_executor_in_use_value`                 |

Example Prometheus expression queries:

```text theme={null}
jenkins_job_count_value
jenkins_plugins_withUpdate
jenkins_job_queuing_duration{quantile="0.95"}
```

Prometheus sample metric lines:

```text theme={null}
jenkins_job_count_value{instance="64.227.187.25:8080", job="jenkins"} 22
jenkins_plugins_withUpdate{instance="64.227.187.25:8080", job="jenkins"} 77
```

Add Prometheus as a Grafana data source

1. Log in to Grafana at `http://<vm-ip>:8081` using the admin credentials.
2. Add a new Prometheus data source. If Grafana and Prometheus are in the same Docker network, use `http://prometheus:9090`. If accessing externally, use `http://<vm-ip>:9090`.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-dark-datasource-jenkins-prometheus-9090.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=422d3a02c7428d19cfdb653d66c95d2e" alt="A dark-themed Grafana settings page for a Prometheus data source named &#x22;Jenkins-Prometheus,&#x22; showing connection details including the Prometheus server URL set to &#x22;http://prometheus:9090.&#x22;" width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-dark-datasource-jenkins-prometheus-9090.jpg" />
</Frame>

Import a Jenkins dashboard
Grafana has community dashboards for Jenkins. Search Grafana Dashboards for "Jenkins" and import one that fits your needs — for example, dashboard ID 9964 ("Jenkins: Performance and Health Overview"). To import:

* In Grafana go to Dashboards → Import
* Enter dashboard ID `9964`, select a name and folder, and map the panels to your Prometheus data source

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-jenkins-performance-health-dashboard.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=424d151a861bb270a02b1eb4eebff531" alt="A Grafana Labs webpage showing a &#x22;Jenkins: Performance and Health Overview&#x22; dashboard screenshot with multiple metrics and graphs. A right-hand panel offers options to get the dashboard (create account, copy ID, download JSON)." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-jenkins-performance-health-dashboard.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-import-jenkins-performance-dashboard.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=3d751d06abdc2acb9d8883225c2b4032" alt="A Grafana &#x22;Import dashboard&#x22; screen showing the process of importing a &#x22;Jenkins: Performance and Health Overview&#x22; dashboard from Grafana.com. The page displays fields for name, folder, UID and selecting a Prometheus data source." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-import-jenkins-performance-dashboard.jpg" />
</Frame>

Generate test metric activity in Jenkins
To see activity in dashboards, create a simple Jenkins Pipeline job and run it repeatedly:

1. Create a new Pipeline job (e.g., `monitor-jenkins`).
2. Use an inline Pipeline script like:

```groovy theme={null}
node {
    stage('Sleep') {
        sh 'sleep 2'
    }
}

node('ubuntu-docker-jdk17-node20') {
    stage('Echo') {
        sh 'echo "1s"'
    }
}
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-new-item-monitor-jenkins-dark.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=870f1ae218d6e79f3f741c92ec71d912" alt="A browser screenshot of the Jenkins &#x22;New Item&#x22; page in dark mode showing the item name field filled with &#x22;monitor-jenkins&#x22; and selectable job types (Freestyle project, Pipeline, Multi-configuration project, Folder). The page includes an OK button at the bottom and standard browser UI at the top." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-new-item-monitor-jenkins-dark.jpg" />
</Frame>

Make sure the node label you reference exists and matches an available agent. The agent label can be verified on the agent details page:

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-agent-ubuntu-docker-jdk17node20.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=2165e38b989e89807cbf6976d9a26d7e" alt="A screenshot of the Jenkins web UI showing the &#x22;Agent ubuntu-agent&#x22; details page. The agent is connected and a label &#x22;ubuntu-docker-jdk17-node20&#x22; is highlighted, with the left sidebar of Jenkins management options visible." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/jenkins-agent-ubuntu-docker-jdk17node20.jpg" />
</Frame>

Trigger the pipeline several times (Build Now). Prometheus will scrape the metrics at its configured interval and Grafana dashboards will begin to reflect the activity. You should see panels for JVM memory, CPU, job counts (total/successful/failed), executor usage, queue durations, and other Jenkins metrics. Customize panels (time series, gauge, heatmap, etc.) and refine PromQL queries to suit your monitoring and alerting needs.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-jenkins-performance-health-dashboard-2.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=e347499c324c64d3b84318a5c8f6b1fa" alt="A Grafana dashboard screenshot showing Jenkins performance and health metrics, with panels for JVM free memory, memory usage, Jenkins health, CPU usage, job counts (total/successful/failed), job duration and executor stats. The left sidebar shows navigation items like Dashboards, Explore, Alerting and Administration." width="1920" height="1080" data-path="images/Advanced-Jenkins/Jenkins-Administration-and-Monitoring/Monitoring-with-Prometheus-Grafana/grafana-jenkins-performance-health-dashboard-2.jpg" />
</Frame>

Prometheus summaries & quantiles
The Prometheus exposition may include quantiles for summaries/histograms. Example for queue durations:

```text theme={null}
jenkins_job_queuing_duration{instance="64.227.187.25:8080", job="jenkins", quantile="0.5"} 7.04
jenkins_job_queuing_duration{instance="64.227.187.25:8080", job="jenkins", quantile="0.95"} 13.0
```

These quantiles help with capacity planning and diagnosing issues like executor saturation or slow builds.

Further reading & references

* Jenkins Prometheus metrics plugin — plugin page (Manage Plugins in Jenkins)
* Prometheus exposition formats — [https://prometheus.io/docs/instrumenting/exposition\_formats/](https://prometheus.io/docs/instrumenting/exposition_formats/)
* Prometheus documentation — [https://prometheus.io/docs/](https://prometheus.io/docs/)
* Grafana dashboards search — [https://grafana.com/grafana/dashboards](https://grafana.com/grafana/dashboards)
* Example dashboard: Jenkins: Performance and Health Overview (ID 9964) — [https://grafana.com/grafana/dashboards/9964](https://grafana.com/grafana/dashboards/9964)

Summary
You now know how to:

* Expose Jenkins metrics via the Prometheus plugin at `/prometheus`
* Configure Prometheus to scrape Jenkins metrics
* Run Prometheus and Grafana with Docker Compose
* Add Prometheus as a Grafana data source and import a Jenkins dashboard
* Generate Jenkins activity to validate the metrics and dashboards

Use the dashboards to monitor Jenkins health, plan capacity, and create alerts when metrics indicate problems (e.g., queue growth or executor saturation).

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/advanced-jenkins/module/fe8b8755-ab0a-429d-ac8c-a7763f723359/lesson/38c29145-23ba-4230-aee1-cefe9984deb4" />
</CardGroup>
