How to Monitor Your Jenkins CI/CD Pipeline with Vigilmon
Jenkins is still the CI/CD workhorse for millions of engineering teams. It's powerful, extensible, and deeply integrated into enterprise build systems. But Jenkins is also notoriously fragile: the master can hang, build agents go offline, disk fills up, and that critical deployment pipeline fails silently at 2 AM.
This guide shows you how to monitor Jenkins with Vigilmon — from simple liveness checks to build agent availability and queue depth monitoring.
Jenkins Has a Built-in Health API
Jenkins exposes a simple health check endpoint out of the box:
GET /login
# Returns 200 when Jenkins is up, 503 during startup
But you can do much better with Jenkins' API:
# Get overall system info (requires auth)
curl -u admin:YOUR_API_TOKEN http://localhost:8080/api/json?pretty=true
# Get queue info
curl -u admin:TOKEN http://localhost:8080/queue/api/json
# Check build executor status
curl -u admin:TOKEN http://localhost:8080/computer/api/json
Step 1: Create a Jenkins Health Proxy
Node.js example:
const express = require('express');
const axios = require('axios');
const app = express();
const JENKINS_URL = process.env.JENKINS_URL;
const JENKINS_AUTH = {
username: process.env.JENKINS_USER,
password: process.env.JENKINS_API_TOKEN
};
app.get('/health/jenkins', async (req, res) => {
try {
// Check Jenkins is alive
const infoRes = await axios.get(`${JENKINS_URL}/api/json`, {
auth: JENKINS_AUTH,
timeout: 5000
});
// Check executor availability
const computersRes = await axios.get(`${JENKINS_URL}/computer/api/json`, {
auth: JENKINS_AUTH,
timeout: 5000
});
const computers = computersRes.data.computer;
const offlineAgents = computers.filter(c => c.offline);
const totalExecutors = infoRes.data.totalExecutors;
const busyExecutors = infoRes.data.usedExecutors;
res.json({
status: 'ok',
total_executors: totalExecutors,
busy_executors: busyExecutors,
offline_agents: offlineAgents.map(a => a.displayName)
});
} catch (err) {
res.status(503).json({ status: 'error', message: err.message });
}
});
Python example:
from fastapi import FastAPI, Response
import httpx
import json
app = FastAPI()
JENKINS_URL = "http://localhost:8080"
JENKINS_AUTH = ("admin", "YOUR_API_TOKEN")
@app.get("/health/jenkins")
async def health_jenkins():
try:
async with httpx.AsyncClient(auth=JENKINS_AUTH, timeout=5.0) as client:
r = await client.get(f"{JENKINS_URL}/api/json")
r.raise_for_status()
data = r.json()
return {
"status": "ok",
"total_executors": data.get("totalExecutors", 0),
"busy_executors": data.get("usedExecutors", 0)
}
except Exception as e:
return Response(content=str(e), status_code=503)
Step 2: Add Vigilmon HTTP Monitor
- Log in to vigilmon.online → Add Monitor
- Type: HTTP(S)
- URL:
https://your-app.com/health/jenkins - Interval: 60 seconds
- Alert if: Status != 200 or response > 5000ms (Jenkins can be slow)
Step 3: Monitor Build Queue Depth
A growing build queue means your executors can't keep up — or all agents are offline:
app.get('/health/jenkins/queue', async (req, res) => {
try {
const queueRes = await axios.get(`${JENKINS_URL}/queue/api/json`, {
auth: JENKINS_AUTH,
timeout: 5000
});
const queueDepth = queueRes.data.items.length;
// Alert if more than 20 builds waiting
if (queueDepth > 20) {
return res.status(503).json({
status: 'queue_overflow',
queue_depth: queueDepth,
waiting_jobs: queueRes.data.items.map(i => i.task?.name)
});
}
res.json({ status: 'ok', queue_depth: queueDepth });
} catch (err) {
res.status(503).json({ status: 'error', message: err.message });
}
});
Step 4: Heartbeat for Critical Scheduled Jobs
For critical Jenkins jobs (nightly builds, data pipelines, compliance checks), add a Vigilmon heartbeat to the end of your Jenkinsfile:
// Jenkinsfile
pipeline {
agent any
triggers {
cron('0 2 * * *') // Run at 2 AM daily
}
stages {
stage('Build') {
steps {
sh 'make build'
}
}
stage('Test') {
steps {
sh 'make test'
}
}
stage('Notify Vigilmon') {
steps {
// Only ping if all previous stages succeeded
sh 'curl -sf https://hb.vigilmon.online/YOUR-HEARTBEAT-ID || true'
}
}
}
}
Configure Vigilmon to alert if no heartbeat is received in 25 hours — catching missed nightly builds immediately.
Jenkins Monitoring Coverage Table
| Monitor | Endpoint | Alerts On |
|---|---|---|
| Jenkins liveness | /health/jenkins |
Master unreachable |
| Build queue | /health/jenkins/queue |
Queue > 20 builds |
| Nightly build | Vigilmon Heartbeat | Build missed or failed |
| SSL certificate | jenkins.yourdomain.com |
Cert expiry < 14 days |
Common Jenkins Failure Patterns
Jenkins master OOM: Jenkins master hit its JVM heap limit during a large parallel build. Master became unresponsive. HTTP monitor caught it within 60 seconds before developers noticed failed pipelines.
All agents offline after server restart: A network switch reboot took all build agents offline. Queue depth grew to 50+ builds. Queue monitor fired; infrastructure team was paged.
Nightly build silently skipped: A Jenkins plugin update broke the trigger mechanism for scheduled jobs. Nightly builds stopped running — but Jenkins showed no errors. Heartbeat monitor caught the missed run at 2:10 AM.
Conclusion
Jenkins monitoring needs both liveness checks (is the master alive?) and operational checks (are agents online, are builds queuing up?). Vigilmon makes it easy to connect all of these through HTTP health endpoints and heartbeat monitors.
Start monitoring your Jenkins pipelines free at vigilmon.online
Top comments (0)