Skip to content

Jenkins - Metrics and Trends

Understanding the performance and trends of your Jenkins builds and the health of the Jenkins instance itself is crucial for maintaining an efficient CI/CD platform. Jenkins offers several ways to track metrics and visualize trends.

  • Build History: The build history list on a job’s page shows recent build statuses (success, unstable, failure), durations, and links to console logs/artifacts.
  • Test Result Trend: If using the junit step, a graph showing the trend of passing, failing, and skipped tests over time is displayed on the job page and test result page.
  • Code Coverage Trend: Code coverage plugins (JaCoCo, Cobertura via Coverage API) often display trend graphs showing coverage percentages over recent builds.
  • Static Analysis Trend: The ‘Warnings Next Generation’ plugin shows trend graphs for the number of issues detected by analysis tools.
  • Pipeline Stage View (Classic UI): The default view for Pipeline jobs shows the duration of each stage, helping identify bottlenecks within your workflow.
  • Blue Ocean Plugin: Provides a more sophisticated graphical view of pipeline execution, including stage durations, parallel step timings, and easy access to logs per stage.
  • Pipeline: Stage Step Measures Plugin: Adds metrics about stage durations to the classic Stage View.

This plugin calculates and displays simple reliability metrics directly on the job page:

  • Mean Time To Failure (MTTF): Average time builds stay successful before failing.
  • Mean Time To Recovery (MTTR): Average time it takes for a job to become successful after failing.
  • Standard Deviation of Build Times: Variability in how long builds take.
  • Installation: Install ‘Build History Metrics plugin’ via Manage Jenkins → Plugins.
  • Usage: Metrics appear automatically on job pages after installation and subsequent builds.

Accessible via Manage Jenkins → Load Statistics. Provides basic graphs showing:

  • Build Queue Length: How many jobs are waiting for an executor.
  • Busy Executors: How many executors (on controller and agents) are currently running builds.
  • Response Time: Basic measure of UI responsiveness.

Useful for a quick health check and identifying chronic resource shortages.

(Formerly Hudson global-build-stats plugin) This plugin aggregates build results across all jobs on the instance and allows creating custom charts.

  • Installation: Install ‘Global Build Stats’ plugin.
  • Configuration: Go to Manage Jenkins → Global Build Stats. Click ‘Initialize stats’ to gather historical data. Click ‘Create new chart’.
  • Chart Creation: Define chart title, size, time scale (daily, weekly), time length, and select jobs to include (or all jobs).
  • Viewing: Charts display build success/failure/unstable trends over the selected period across the chosen jobs.
Section titled “Monitoring Plugin (Prometheus Integration - Recommended)”

For comprehensive monitoring, the ‘Monitoring’ plugin is highly recommended. It exposes detailed Jenkins internal metrics in a format compatible with monitoring systems like Prometheus.

  • Installation: Install ‘Monitoring’ plugin.
  • Configuration: Provides an endpoint (usually /prometheus or /metrics/<api_key>) that Prometheus can scrape.
  • Metrics Exposed: Includes JVM metrics (memory, GC, threads), executor usage, agent status, queue length, job health, build durations, plugin stats, and much more.
  • Visualization: Use Grafana with a Prometheus data source to create powerful dashboards visualizing Jenkins health and performance over time.
  • Benefits: Provides deep insights, allows setting up alerts based on metrics (e.g., alert if queue length exceeds threshold), and integrates Jenkins into your standard infrastructure monitoring.

Start with the built-in metrics and Pipeline visualizations. For more detailed job reliability insights, use the ‘Build History Metrics’ plugin. For instance-wide trends, ‘Global Build Stats’ offers simple charts. For robust, production-grade monitoring and alerting, implement the ‘Monitoring’ plugin with Prometheus and Grafana.