- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Monitoring Containerized Application Health with Docker
Monitoring the health of your Docker host and its hosted containers ensures that you are aware of any issues—and potential issues—your containers may encounter. By leveraging tools like Docker healthchecks, cAdvisor, Prometheus, and Grafana, you gain insight into not just problems, but also gather important data about resource usage and application health and general functionality. In this lab, you will set up a full monitoring and health check stack to ensure you have deep insight into the happenings of your Docker setup.
Lab Info
Table of Contents
-
Challenge
Prepare Docker for deploying the monitoring stack
Configure Docker to expose host metrics using a wildcard address on the Prometheus-compatible metrics port, then create the
monitoringnetwork separate from the existing service network to host cAdvisor, Prometheus, and Grafana. -
Challenge
Deploy cAdvisor and confirm its gathering metrics
Run cAdvisor as a Docker container, ensuring it uses the recommended configuration to collect metrics data, is hosted on the
monitoringnetwork, and uses theghcr.io/google/cadvisor:v0.60.5image. Ensure this metrics data is available by navigating the cAdvisor web UI and verifying it populates data from the runningjobqueueservice. -
Challenge
Update the job queue service to expose a health check endpoint
Update the Dockerfile for the existing job queue microservice to include a
HEALTHCHECKwith an interval of5seconds, a timeout of3seconds, a start period of25seconds, and3retries for the existing/healthzendpoint. Rebuild the image, redeploy the microservice, then monitor the service health, waiting a bit for it to become(healthy). -
Challenge
Deploy Prometheus and configure it to monitor the Docker host and applications
Deploy a Prometheus container using a
prometheus.ymlconfiguration file stored in a newly-created~/prometheusdirectory. This file should define thedocker-hostmetrics endpoint,cadvisor, and the providedjobqueueapplication endpoint at port5000as scrape targets. Verify these endpoints are working by checking the Prometheus dashboard UI and running a few queries. -
Challenge
Deploy Grafana and build a dashboard
- Deploy Grafana as a Docker container.
- Using the UI, change the Grafana password to
astrongpassword, then set up Prometheus as a data source. - Configure a dashboard called
Job Queue Service Dashboardwith a panel calledCPU Usageto show CPU usage over time (1 minute) for the job queue service, using a time-series visualization.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.