14 Monitoring applications and Kubernetes with Prometheus

 

Monitoring is the companion to logging: your monitoring system tells you something is wrong, and then you can dig into the logs to find out the details. Like logging, you want to have a centralized system to collect and visualize metrics about all your application components. An established approach for monitoring in Kubernetes uses another CNCF project: Prometheus, which is a server application that collects and stores metrics. In this chapter, you’ll learn how to deploy a shared monitoring system in Kubernetes with dashboards that show the health of individual applications and the cluster as a whole.

Prometheus runs on many platforms, but it’s particularly well suited to Kubernetes. You run Prometheus in a Pod that has access to the Kubernetes API server, and then Prometheus queries the API to find all the targets it needs to monitor. When you deploy new apps, you don’t need to make any setup changes—Prometheus discovers them automatically and starts collecting metrics. Kubernetes apps are particularly well suited to Prometheus, too. You’ll see in this chapter how to make good use of the sidecar pattern, so every app can provide some metrics to Prometheus, even if the application itself isn’t Prometheus-ready.

14.1 How Prometheus monitors Kubernetes workloads

14.2 Monitoring apps built with Prometheus client libraries

14.3 Monitoring third-party apps with metrics exporters

14.4 Monitoring containers and Kubernetes objects

14.5 Understanding the investment you make in monitoring

14.6 Lab