Devops

Using Prometheus to Monitor Jenkins Pipelines and Infrastructure

April 7, 2026
Published
#CI/CD#DevOps#Jenkins#Monitoring#Prometheus

When a Jenkins pipeline slows down or fails unpredictably, most teams start digging through logs. That works—until it doesn’t. At some point, you need real visibility into what’s happening over time. That’s where Prometheus fits in.

Prometheus gives you time-series metrics, alerting, and a structured way to understand your CI/CD system. Pair it with Jenkins, and you move from reactive debugging to proactive monitoring.

What Prometheus Actually Brings to Jenkins

Jenkins already exposes some internal metrics, but they’re not very useful on their own. Prometheus turns those into:

  • Historical trends (build duration, queue time)
  • Real-time monitoring of pipeline health
  • Alerting when builds fail or slow down
  • Capacity insights for agents and executors

Instead of asking “why did this fail?”, you start asking “when did this start degrading?”

Quick Setup: Jenkins + Prometheus Plugin

The easiest way to get started is the Prometheus Metrics Plugin in Jenkins.

  1. Go to Manage Jenkins → Plugins
  2. Install Prometheus metrics plugin
  3. Restart Jenkins

Once installed, Jenkins exposes a metrics endpoint:

/prometheus

This endpoint returns metrics in a format Prometheus understands.

Example metrics you’ll see

  • jenkins_job_duration_seconds
  • jenkins_queue_size
  • jenkins_executor_count
  • jenkins_builds_total

These are raw but powerful when aggregated.

Configuring Prometheus to Scrape Jenkins

Now comes the interesting part—telling Prometheus where to pull metrics from.

In your prometheus.yml:

YAML
1scrape_configs:
2  - job_name: 'jenkins'
3    metrics_path: '/prometheus'
4    static_configs:
5      - targets: ['localhost:8080']

If Jenkins runs in Docker or Kubernetes, replace localhost:8080 with the appropriate service name.

After restarting Prometheus, it begins collecting Jenkins metrics automatically.

Let’s Make It Real: Tracking Build Duration

A common question: are builds getting slower?

With Prometheus, you can query:

TEXT
1rate(jenkins_job_duration_seconds_sum[5m])
2/
3rate(jenkins_job_duration_seconds_count[5m])

This gives you the average build duration over time.

Hook this into Grafana, and suddenly you have a dashboard showing trends across days or weeks.

Where Things Get Interesting: Alerts

Metrics are useful, but alerts are where Prometheus starts saving time.

Example alert rule:

YAML
1groups:
2- name: jenkins-alerts
3  rules:
4  - alert: HighBuildFailureRate
5    expr: rate(jenkins_builds_failed_total[10m]) > 5
6    for: 5m
7    labels:
8      severity: warning
9    annotations:
10      summary: "High Jenkins build failure rate"
11

This triggers when failures spike, not just when a single build breaks.

Monitoring Jenkins Agents and Executors

One subtle issue in Jenkins setups is resource starvation. Pipelines queue up, but the root cause isn’t obvious.

Prometheus helps by exposing:

  • Executor usage
  • Queue length
  • Idle vs busy nodes

Example query:

TEXT
1jenkins_queue_size

If this keeps growing, your agents can’t keep up.

A better signal combines multiple metrics:

TEXT
1jenkins_queue_size / jenkins_executor_count

This ratio quickly shows saturation.

Docker-Based Setup (Minimal Example)

If you want a quick local setup for testing:

YAML
1version: '3'
2services:
3  jenkins:
4    image: jenkins/jenkins:lts
5    ports:
6      - "8080:8080"
7
8  prometheus:
9    image: prom/prometheus
10    volumes:
11      - ./prometheus.yml:/etc/prometheus/prometheus.yml
12    ports:
13      - "9090:9090"

This gives you a working environment in minutes.

Common Mistakes Developers Make

There are a few patterns that show up repeatedly:

  • Scraping too infrequently — You lose useful granularity
  • No labeling strategy — Makes queries messy later
  • Ignoring pipeline-level metrics — Only tracking system metrics
  • No alert tuning — Either too noisy or completely silent

Monitoring only works if the signals are meaningful.

Adding Grafana for Visualization

Prometheus stores the data, but Grafana makes it readable.

Typical Jenkins dashboards include:

  • Build success vs failure rates
  • Pipeline duration trends
  • Queue wait time
  • Executor utilization

You don’t need to build these from scratch—Grafana has community dashboards for Jenkins + Prometheus.

When This Setup Really Pays Off

This integration shines in teams that:

  • Run many parallel pipelines
  • Use dynamic agents (Kubernetes, cloud)
  • Care about build performance over time
  • Need alerting instead of manual checking

If your Jenkins instance is small, logs might be enough. But once things scale, metrics become essential.

Final Thought

Prometheus doesn’t replace Jenkins—it makes it observable. And once you can see what’s happening in your pipelines, optimizing them becomes much easier.

Start simple: enable the plugin, scrape metrics, and build one dashboard. The value shows up quickly.

Comments

Leave a comment on this article with your name, email, and message.

Loading comments...

Similar Articles

More posts from the same category you may want to read next.

Share: