Monitor and Troubleshoot Jenkins: Logs, Metrics, Prometheus, Disk, Memory, Queue Problems and Common Errors

CI CD Pipelines with Jenkins 40 min min read Updated: Nov 17, 2026 Intermediate
Monitor and Troubleshoot Jenkins: Logs, Metrics, Prometheus, Disk, Memory, Queue Problems and Common Errors
Intermediate Topic 3 of 3

What to Watch

SignalWhy it mattersWarning sign
Build queue length and wait timeDevelopers wait for executorsQueue grows for many minutes
Executor usageCapacityAlways 100 percent busy
Agent statusOffline agents reduce capacityAgents offline, flapping
JVM heap and GC timeController stabilityHeap near full, long pauses
Disk free on JENKINS_HOME and agentsBuilds fail when disk is fullUnder 20 percent free
Build success rate and durationPipeline healthSudden increase in failures or time
HTTP response timeUI speedSlow pages, timeouts

Prometheus and Grafana

  1. Install the Prometheus metrics plugin (prometheus)
  2. Metrics appear at /prometheus/ (protect with authentication or an allow-list)
  3. Add a scrape job in Prometheus
  4. Import a Jenkins dashboard in Grafana, then create alerts
yaml # prometheus.yml scrape_configs: - job_name: jenkins metrics_path: /prometheus/ scheme: https authorization: credentials_file: /etc/prometheus/jenkins.token static_configs: - targets: ["jenkins.example.com"]
yaml # alert rules (examples) groups: - name: jenkins rules: - alert: JenkinsQueueLong expr: jenkins_queue_size_value > 20 for: 10m labels: {severity: warning} annotations: {summary: "Jenkins queue has more than 20 items for 10 minutes"} - alert: JenkinsNodesOffline expr: jenkins_node_offline_value > 0 for: 15m labels: {severity: warning} - alert: JenkinsDiskLow expr: (node_filesystem_avail_bytes{mountpoint="/var/lib/jenkins"} / node_filesystem_size_bytes{mountpoint="/var/lib/jenkins"}) < 0.15 for: 10m labels: {severity: critical}
Check metric names: Names can vary with plugin versions. Open the /prometheus/ page of your Jenkins and copy the exact metric names into your queries.

Where the Logs Are

LogLocation
Build (console) logJob page → Console Output; file jobs/NAME/builds/N/log
Jenkins system logManage Jenkins → System Log; or journalctl -u jenkins, or /var/log/jenkins/jenkins.log
Agent logNode page → Log
Dockerdocker logs jenkins
Kuberneteskubectl logs deploy/jenkins, and agent pod logs
Reverse proxynginx access.log and error.log
bash sudo journalctl -u jenkins --since "1 hour ago" --no-pager | grep -iE "severe|exception|outofmemory" docker logs --since 1h jenkins 2>&1 | grep -iE "severe|exception"
  • Add a log recorder (Manage Jenkins → System Log → Add new log recorder) for a class such as hudson.slaves at FINE level to debug agents, then switch it off
  • Send logs to a central system to search across time

Memory and the JVM

ini # Example JAVA_OPTS for a controller with 8 GB RAM JAVA_OPTS="-Xms2g -Xmx4g -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jenkins/ -Djava.awt.headless=true"
SettingMeaning
-Xms / -XmxStart and maximum heap. Set both the same for steady behavior
-XX:+UseG1GCG1 garbage collector, a good default
-XX:+HeapDumpOnOutOfMemoryErrorSave a heap dump on crash for later analysis
Leave memory for the OSDo not give Java all RAM; metaspace and native memory need space
  • Symptoms of memory trouble: UI slow, builds stall, java.lang.OutOfMemoryError in logs
  • Common causes: too many jobs with long history, heavy plugins, huge Groovy data, many parallel pipelines
  • Fixes: raise heap moderately, discard old builds, remove unused plugins, move work to agents, split into multiple controllers

Disk Space

bash df -h /var/lib/jenkins sudo du -sh /var/lib/jenkins/* | sort -h | tail sudo du -sh /var/lib/jenkins/jobs/*/builds | sort -h | tail docker system df # on agents docker system prune -af --volumes # careful: removes unused images and volumes
  • Set Discard old builds (days and count) on every job, or buildDiscarder in pipelines
  • Use cleanWs() at the end of pipelines and clean workspace policies on agents
  • Archive only needed artifacts and keep them in Nexus/Artifactory/S3
  • Schedule a cleanup job for agents: old Docker images, volumes, Maven or npm caches

Queue and Executor Problems

Message / symptomLikely causeFix
Waiting for next available executorAll executors busyAdd agents, reduce parallelism, shorten builds
There are no nodes with the label 'x'Label typo or no agent has itFix the label or add the node
'x' is offlineAgent disconnectedCheck agent log, network, Java, restart
Jobs wait while executors are idleExclusive mode, or label mismatch, or resource lockCheck node usage mode, labels, lockable resources
Queue item stuck: PendingWaiting for a Kubernetes pod or cloud agent to startCheck cloud quota, pod events, image pull

Agent Connection Problems

ErrorCheck
java.net.ConnectException: Connection refusedAgent port, firewall, WebSocket setting, URL
SSH: Authentication failedCredential, key format, user, authorized_keys
Host key verification failedKnown hosts strategy, or add the host key
UnsupportedClassVersionErrorAgent Java is older than required. Update Java on the agent
Agent keeps disconnectingNetwork timeouts, load balancer idle timeout, low memory on the agent
Cannot connect... 403 or No valid crumbReverse proxy headers, Jenkins URL, or security settings

Pipeline Problems

SymptomWhat to try
Pipeline stuck, no outputCheck for input waiting, a lock waiting, or a process that never ends. Add timeout
groovy.lang.MissingMethodExceptionPlugin missing, step typo, or wrong arguments. Use the Pipeline Syntax snippet generator
RejectedAccessException / Scripts not permittedSandbox blocked a method. Approve only if safe, or move logic to a library
NotSerializableExceptionNon-serializable object held across steps. Use @NonCPS or simpler data
WorkflowScript: unable to resolve classMissing import or shared library not loaded (@Library)
Build works locally, fails in JenkinsDifferent tool versions, environment variables, user, or missing files. Print env, pwd, whoami (without secrets)
Permission denied for DockerJenkins user is not in the docker group, or socket not mounted

Thread Dump and Support Bundle

  • When Jenkins is slow or frozen: take a thread dump (Manage Jenkins → System Information → Thread dumps, or jstack PID) and look for blocked threads or lock waits
  • The Support Core plugin makes a support bundle (logs, configuration, plugin list, thread dumps) to share with teammates or vendors
  • Check /manage/log/ and the Administrative monitors banners in Manage Jenkins first
bash PID=$(pgrep -f jenkins.war) jstack $PID > /tmp/jenkins-threads-$(date +%s).txt jcmd $PID GC.heap_info

Troubleshooting Routine

  1. Define the problem: what failed, since when, for whom
  2. Check recent changes: plugin update, config change, new job, infrastructure change
  3. Read the log around the first error, not the last one
  4. Check resources: disk, memory, CPU, network
  5. Reproduce on a test job or agent
  6. Fix, then write down the cause and add a monitor or alert

Practice Tasks

  1. Install the Prometheus plugin and view metrics in your browser
  2. Create a Grafana panel for queue size and executor usage
  3. Fill a lab disk and observe failures, then add buildDiscarder and clean up
  4. Break an agent label on purpose and read the queue message
  5. Take a thread dump and a support bundle on a lab Jenkins

Conclusion

Watch queue, executors, agents, JVM heap, disk and build health with Prometheus and Grafana, read system and build logs, tune the heap, discard old builds, and use a routine for errors: define, check changes, read first errors, check resources, reproduce, fix and record. Thread dumps and support bundles help with hard cases.

Quick Summary: signals table; Prometheus plugin + alerts; log locations; JVM options; disk cleanup; queue/agent/pipeline error tables; thread dump + support bundle; routine.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators