Docker Monitoring Stack

Monitor your Linux containers with Prometheus, Grafana, Node Exporter, and cAdvisor

Monitoring Services

Grafana

Visualization platform with customizable dashboards for your metrics.

Prometheus

Time-series database for collecting and querying metrics.

cAdvisor

Container resource usage and performance characteristics.

Node Exporter

Exports hardware and OS metrics from 10 Linux containers.

Ports 9101-9110

Setup Instructions

Quick Start

# Clone the repository

git clone https://github.com/sameeralam3127/monitoring.git

cd monitoring

# Build and start the stack

docker-compose up -d --build

Requirements

  • Docker installed
  • Docker Compose installed
  • At least 4GB RAM available

Configuration

  • Prometheus config: prometheus/prometheus.yml
  • Grafana dashboards: grafana/dashboard.json

Example Prometheus Queries

CPU Metrics

# CPU usage per container

rate(node_cpu_seconds_total{mode="user"}[5m])

# Docker container CPU usage

rate(container_cpu_usage_seconds_total{name=~".+"}[5m])

Memory Metrics

# Memory usage percentage

node_memory_Active_bytes / node_memory_MemTotal_bytes * 100

System Metrics

# Running services (systemd)

node_systemd_unit_state{state="active"}

# Logged-in users

node_users_logged_in

Error Metrics

# Failed services

node_systemd_unit_state{state="failed"}