13 Collecting continuous delivery metrics

 

This chapter covers

  • Monitoring Jenkins and its jobs effectively
  • Forwarding Jenkins build logs to a centralized logging platform
  • Parsing Jenkins logs into something structured and queryable
  • Exposing Jenkins internal metrics with Prometheus
  • Building interactive dashboards with Grafana
  • Creating metric-based alerts for Jenkins

In the previous chapters, you learned to design, build, and deploy a Jenkins cluster from scratch by using automation tools; you also learned to set up a fully working CI/CD pipeline for several cloud-native applications. In this chapter, we will dive into advanced Jenkins topics: monitoring a running Jenkins server and detecting anomalies and resource starvation. Along the way, we will cover how to build a centralized logging platform for Jenkins logs.

13.1 Monitoring Jenkins cluster health

The cluster we built in chapter 5 consists of a Jenkins master and workers, with each node running inside an EC2 instance. Figure 13.1 shows a typical Jenkins node configuration.

Figure 13.1 Jenkins distributed build architecture

So far, the Jenkins cluster is working as expected. However, you should never take your IT infrastructure for granted. Your Jenkins master or workers one day will break and will need to be replaced. So, how do you know if your Jenkins cluster is working effectively if you aren’t monitoring it?

13.2 Centralized logging for Jenkins logs with ELK

13.2.1 Streaming logs with Filebeat

13.2.2 Streaming logs with the Logstash plugin

13.3 Creating alerts based on metrics

Summary