Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Prometheus monitor Docker Swarm clusters

Shulou Source: shulou.com Published: 2022-05-31 20:09:40 09月22日 Update

This article introduces the knowledge of "how Prometheus monitors Docker Swarm clusters". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to cAdvisor

In order to solve the problem of container monitoring, Google developed a container monitoring tool cAdvisor (Container Advisor), which provides container users with a visual display of the resource usage and performance characteristics of their running containers. It is a running daemon that collects, aggregates, processes, and exports information about running containers.

CAdvisor can real-time monitor and collect performance data of resources and containers on node machines, including CPU, memory, network and file system usage.

CAdvisor is developed in go language. If you want to know more, please visit its official github

Install cAdvisor

CAdvisor has two ways to run, one is to install and run as a binary executable file, configure systemd to manage, the other is to run as a Docker container, using docker-compose to manage, here we only talk about docker deployment and management methods.

We can run the cAdvisor container on the virtual machine of the lab environment with the following command:

Start in Docker mode

Docker run\

-- volume=/:/rootfs:ro\

-- volume=/var/run:/var/run:rw\

-- volume=/sys:/sys:ro\

-- volume=/var/lib/docker/:/var/lib/docker:ro\

-- volume=/dev/disk/:/dev/disk:ro\

-- publish=18080:18080\

-- detach=true\

-- name=cadvisor\

Google/cadvisor:latest

The above startup methods are a bit cumbersome for management. In order to facilitate management, we use docker-compose to manage

Install docker-compose

Curl-L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname-s)-$(uname-m)"-o / usr/local/bin/docker-compose

Chmod + x / usr/local/bin/docker-compose

Mkdir-p / data/docker-monitor/

Docker-compose file

Cat > docker-compose.yml

Tags: Containers monitoring running management files configuration passwords methods methods more clusters content performance situations data knowledge resources development related intuitive Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei Xiaomi Shulou Technology MySQL