Monitoring & Health
Quick Health Check
Section titled “Quick Health Check”Run these commands to get a snapshot of the cluster:
# Are all nodes healthy?docker node ls
# Are all services running?docker service ls | grep -v "1/1\|0/0"
# Any failed tasks?docker stack ps dev --filter "desired-state=shutdown" --format "{{.Name}} {{.Error}}"docker stack ps uat --filter "desired-state=shutdown" --format "{{.Name}} {{.Error}}"docker stack ps shared --filter "desired-state=shutdown" --format "{{.Name}} {{.Error}}"If docker service ls shows services with 0/1 replicas, those services are down.
Portainer Dashboard
Section titled “Portainer Dashboard”Portainer provides a web UI for monitoring at:
| URL | Access |
|---|---|
https://portainer.ayinza.dev | Admin credentials |
From Portainer you can:
- View all stacks, services, and containers
- See resource usage (CPU, memory) per container
- Read container logs
- Restart services
- View cluster node status
Checking Individual Services
Section titled “Checking Individual Services”Service Status
Section titled “Service Status”# See if a service is runningdocker service ps dev_api
# Output columns: ID, NAME, IMAGE, NODE, DESIRED STATE, CURRENT STATE, ERROR# Look for "Running" in CURRENT STATEService Logs
Section titled “Service Logs”# Tail logs in real timedocker service logs dev_api --tail 200 -f
# Logs with timestampsdocker service logs dev_api --tail 200 -f -t
# Logs for a specific time range (last 30 minutes)docker service logs dev_api --since 30mContainer Resource Usage
Section titled “Container Resource Usage”# Live resource stats for all containers on this nodedocker stats
# Stats for a specific containerdocker stats <container_id>Server-Level Monitoring
Section titled “Server-Level Monitoring”Disk Usage
Section titled “Disk Usage”# Overall disk usagedf -h
# Docker-specific disk usagedocker system df
# Largest directoriesdu -sh /data/* 2>/dev/null | sort -rh | head -10 # Contabodu -sh /var/lib/docker/volumes/* | sort -rh | head -10Memory Usage
Section titled “Memory Usage”# Quick overviewfree -h
# Detailed per-process memoryps aux --sort=-%mem | head -20CPU Usage
Section titled “CPU Usage”# Interactive process monitortop
# Snapshot of top CPU consumersps aux --sort=-%cpu | head -20Network
Section titled “Network”# Check open portsss -tlnp
# Check WireGuard tunnelwg show
# Test connectivity between nodesping 10.10.0.1 # Azureping 10.10.0.2 # ContaboCommon Health Indicators
Section titled “Common Health Indicators”| What to Check | Healthy | Unhealthy |
|---|---|---|
docker node ls | Both nodes Ready + Active | Node shows Down or Drain |
docker service ls | All services show 1/1 | Any service shows 0/1 |
df -h | Disk usage < 80% | Disk usage > 90% |
free -h | Free memory > 1 GB | Free memory < 500 MB |
wg show | Shows peer with recent handshake | No peer or handshake > 5 min ago |
| Portainer UI | Loads and shows all services | Unreachable or shows errors |
Setting Up Alerts (Recommended)
Section titled “Setting Up Alerts (Recommended)”Currently there is no automated alerting. A basic monitoring setup could include:
- Cron-based health check — Script that runs every 5 minutes, checks
docker service lsfor unhealthy services, and sends a notification - Disk space monitor — Alert when disk usage exceeds 80%
- Uptime monitoring — External service (e.g., UptimeRobot) pinging key URLs
Simple Health Check Script
Section titled “Simple Health Check Script”#!/bin/bash# Save as /home/kaks/health-check.sh# Add to cron: */5 * * * * /home/kaks/health-check.sh
UNHEALTHY=$(docker service ls --format "{{.Name}} {{.Replicas}}" | grep "0/")
if [ -n "$UNHEALTHY" ]; then echo "ALERT: Unhealthy services detected:" echo "$UNHEALTHY" # Add notification here (email, Slack webhook, etc.)fi