Skip to main content

Docker Daemon Monitoring with Prometheus

Hands-On Lab

 

Photo of Will Boyd

Will Boyd

DevOps Team Lead in Content

Length

00:45:00

Difficulty

Intermediate

Prometheus is capable of monitoring a wide variety of systems and infrastructures, including Docker. In this lab, you will have the opportunity to set up Prometheus to monitor a Docker daemon. This will give you some hands-on experience with the process of monitoring Docker daemons with Prometheus.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Docker Daemon Monitoring with Prometheus

Introduction

Prometheus is capable of monitoring a wide variety of systems and infrastructures, including Docker. In this lab, you will have the opportunity to set up Prometheus to monitor a Docker daemon. This will give you some hands-on experience with the process of monitoring Docker daemons with Prometheus.

Solution

Log in to the Docker server using the credentials provided:

ssh cloud_user@<DOCKER_SERVER_PUBLIC_IP>

Configure the Docker Daemon to Serve Prometheus Metrics

  1. Create the Docker config file:

    sudo vi /etc/docker/daemon.json
  2. Add configuration to enable experimental mode and set the metrics address:

    {
      "experimental": true,
      "metrics-addr": "10.0.1.102:9323"
    }
  3. Save and exit the file by pressing Escape followed by :wq.

  4. Restart Docker to load the new configuration:

    sudo systemctl restart docker
  5. Verify Docker is serving Prometheus metrics:

    curl 10.0.1.102:9323/metrics

    We should see a lot of data returned.

Configure Prometheus to Scrape Docker Metrics

  1. Open a new terminal.

  2. Log in to the Prometheus server:

    ssh cloud_user@<PROMETHEUS_SERVER_PUBLIC_IP>
  3. Edit the Prometheus config:

    sudo vi /etc/prometheus/prometheus.yml
  4. Under the scrape_configs section, add a scrape configuration for Docker:

    - job_name: 'Docker'
      static_configs:
      - targets: ['limedrop-docker:9323']
  5. Save and exit the file by pressing Escape followed by :wq.

  6. Restart Prometheus to load the new configuration:

    sudo systemctl restart prometheus
  7. Access the expression browser in a web browser at http://<PROMETHEUS_SERVER_PUBLIC_IP>:9090.

  8. Run a query to view some Docker metric data:

    engine_daemon_container_states_containers

    We should see some data returned.

Conclusion

Congratulations on successfully completing this hands-on lab!