Operations 6 min read

Building a Visual Monitoring Center for Docker Containers with InfluxDB, cAdvisor, and Grafana

This tutorial walks through deploying InfluxDB, cAdvisor, and Grafana containers, configuring them to collect and visualize time‑series metrics such as CPU, memory, network, and disk usage from Docker workloads, and shows how to create dashboards and queries for effective container monitoring.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Building a Visual Monitoring Center for Docker Containers with InfluxDB, cAdvisor, and Grafana

In a single host you can run multiple containerized applications, and to manage them you need to monitor CPU usage, memory consumption, network status, and disk space—collectively time‑series data. This article demonstrates how to build a visual monitoring center that gathers and displays these metrics.

Preparation : three Docker images are required— adviser (collects metrics), influxdb (stores time‑series data), and grafana (visualizes data).

Deploy InfluxDB as a time‑series database:

docker run -d -p 8086:8086 \
  -v ~/influxdb:/var/lib/influxdb \
  --name influxdb tutum/influxdb

Enter the container and create a database and a root user:

docker exec -it influxdb influx
CREATE DATABASE "test"
CREATE USER "root" WITH PASSWORD 'root' WITH ALL PRIVILEGES

Deploy cAdvisor to collect container metrics and send them to InfluxDB:

docker run -d \
  -v /:/rootfs -v /var/run:/var/run -v /sys:/sys \
  -v /var/lib/docker:/var/lib/docker \
  --link=influxdb:influxdb --name cadvisor google/cadvisor:v0.27.3 \
  --storage_driver=influxdb \
  --storage_driver_host=influxdb:8086 \
  --storage_driver_db=test \
  --storage_driver_user=root \
  --storage_driver_password=root

For CentOS/RHEL you may need to add --privileged=true and --volume=/cgroup:/cgroup:ro to give the container proper permissions.

Deploy Grafana for visualization:

docker run -d -p 5000:3000 \
  -v ~/grafana:/var/lib/grafana \
  --link=influxdb:influxdb \
  --name grafana grafana/grafana

All three containers are now running. Access Grafana at http://localhost:5000 (default login: admin / admin). After logging in, add InfluxDB as a data source, then create a dashboard.

In the dashboard, add a panel, edit it, and select the desired metric (e.g., memory usage) and the target container (Grafana, InfluxDB, or cAdvisor). Multiple queries can be added to monitor several containers simultaneously.

The resulting graph shows memory usage for the three containers, demonstrating a clear, real‑time view of container performance. Additional customizations such as axis settings, display options, and alert rules are also possible.

Feel free to experiment and build your own monitoring setup.

monitoringDockeropsInfluxDBGrafanaTimeSeriescAdvisor
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.