Fatskills
Practice. Master. Repeat.
Study Guide: Docker: Logging and Monitoring - Integrating with Prometheus, cAdvisor, Google Cloud Monitoring, Datadog, New Relic
Source: https://www.fatskills.com/kubernetes/chapter/docker-docker-logging-and-monitoring-integrating-with-prometheus-cadvisor-google-cloud-monitoring-datadog-new-relic

Docker: Logging and Monitoring - Integrating with Prometheus, cAdvisor, Google Cloud Monitoring, Datadog, New Relic

By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.

⏱️ ~3 min read

1. Core Command / Concept

Integrate Docker with Prometheus for container monitoring. docker run -d --name prometheus -p 9090:9090 prometheus/prometheus

2. Step-by-Step (numbered)

  1. Install Docker on your system (if not already installed). ```bash sudo apt-get update && sudo apt-get install docker.io
2. Pull the Prometheus image from Docker Hub.
   ```bash
docker pull prometheus/prometheus
  1. Run Prometheus in detached mode (-d) and map port 9090. ```bash docker run -d --name prometheus -p 9090:9090 prometheus/prometheus
4. Verify Prometheus is running and listening on port 9090.
   ```bash
docker exec -it prometheus /bin/bash -c "curl http://localhost:9090"
  1. Clean up by stopping and removing the Prometheus container. This deletes all stopped containers. bash docker stop prometheus && docker rm prometheus

3. Real Commands with Examples

Example 1: Running cAdvisor

  • Purpose: Monitor Docker containers with cAdvisor.
  • Command: docker run -d --name cadvisor -p 8080:8080 google/cadvisor
  • Brief explanation of flags: -d runs the container in detached mode, -p maps port 8080 from the container to the host.

Example 2: Running Google Cloud Monitoring

  • Purpose: Monitor Docker containers with Google Cloud Monitoring.
  • Command: docker run -d --name gcm -p 8080:8080 google/cloud-monitoring
  • Brief explanation of flags: -d runs the container in detached mode, -p maps port 8080 from the container to the host.

Example 3: Running Datadog

  • Purpose: Monitor Docker containers with Datadog.
  • Command: docker run -d --name datadog -p 8125:8125 datadog/docker-dd-agent
  • Brief explanation of flags: -d runs the container in detached mode, -p maps port 8125 from the container to the host.

4. Common Errors (3-5)

Error 1: Prometheus not running

  • Error message or symptom: Prometheus not listening on port 9090.
  • Why it happens: Prometheus container not started or not running.
  • One-line fix: docker start prometheus && docker exec -it prometheus /bin/bash -c "curl http://localhost:9090"

Error 2: cAdvisor not running

  • Error message or symptom: cAdvisor not listening on port 8080.
  • Why it happens: cAdvisor container not started or not running.
  • One-line fix: docker start cadvisor && docker exec -it cadvisor /bin/bash -c "curl http://localhost:8080"

Error 3: Google Cloud Monitoring not running

  • Error message or symptom: Google Cloud Monitoring not listening on port 8080.
  • Why it happens: Google Cloud Monitoring container not started or not running.
  • One-line fix: docker start gcm && docker exec -it gcm /bin/bash -c "curl http://localhost:8080"

5. Quick Checks (3 scenarios)

Scenario 1: Prometheus running

  • Situation: Prometheus container running and listening on port 9090.
  • Command: docker exec -it prometheus /bin/bash -c "curl http://localhost:9090"
  • What a correct response looks like: Prometheus dashboard displayed in the browser.

Scenario 2: cAdvisor running

  • Situation: cAdvisor container running and listening on port 8080.
  • Command: docker exec -it cadvisor /bin/bash -c "curl http://localhost:8080"
  • What a correct response looks like: cAdvisor dashboard displayed in the browser.

Scenario 3: Google Cloud Monitoring running

  • Situation: Google Cloud Monitoring container running and listening on port 8080.
  • Command: docker exec -it gcm /bin/bash -c "curl http://localhost:8080"
  • What a correct response looks like: Google Cloud Monitoring dashboard displayed in the browser.

6. Last-Minute Reference

  • Prometheus port: 9090
  • cAdvisor port: 8080
  • Google Cloud Monitoring port: 8080
  • Datadog port: 8125
  • Docker Hub: hub.docker.com
  • Docker Hub image: prometheus/prometheus
  • Docker Hub image: google/cadvisor
  • Docker Hub image: google/cloud-monitoring
  • Docker Hub image: datadog/docker-dd-agent
  • Docker containers are deleted when stopped if not persisted.
  • Docker images are deleted when removed if not persisted.
  • Docker volumes are deleted when removed if not persisted.